Search Results

Search found 6 results on 1 pages for 'ekapek'.

Page 1/1 | 1 

  • PyQt4 and QTableView with spinbox and checkbox

    - by ekapek
    Hi, I have a QTableView with QSqlTableModel and with 3 columns, now I need to have: - second column: spinbox after clicked to edit - third column: checkbox (displayed center) My code: class SpinBoxDelegate(QtGui.QItemDelegate): def createEditor(self, parent, option, index): editor = QtGui.QSpinBox(parent) editor.setMinimum(0) editor.setMaximum(100) print 'spinbox' return editor def setEditorData(self, spinBox, index): value = index.model().data(index, QtCore.Qt.EditRole).toInt()[0] spinBox.setValue(value) def setModelData(self, spinBox, model, index): spinBox.interpretText() value = spinBox.value() model.setData(index, value, QtCore.Qt.EditRole) def updateEditorGeometry(self, editor, option, index): editor.setGeometry(option.rect) class myQSqlTableModel(QtSql.QSqlTableModel): def flags(self,index): result = QtSql.QSqlTableModel.flags(self,index); if index.column() == 2: result |= QtCore.Qt.ItemIsUserCheckable return result def data(self,index,role): if not index.isValid: return QtCore.QVariant() value = QtSql.QSqlTableModel.data(self, index, role) if index.column() == 2: if role == QtCore.Qt.CheckStateRole: return QtCore.Qt.Unchecked if QtSql.QSqlTableModel.data(self, index).toInt()[0] else QtCore.Qt.Checked elif role == QtCore.Qt.DisplayRole: return QtCore.QVariant() return value and self.model = myQSqlTableModel(self) self.model.setTable("person") self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit) self.model.select(): self.model.setHeaderData(0, QtCore.Qt.Horizontal, self.tr("ID")) self.model.setHeaderData(1, QtCore.Qt.Horizontal, self.tr("A")) self.model.setHeaderData(2, QtCore.Qt.Horizontal, self.tr("B")) self.view = QtGui.QTableView() self.view.setModel(self.model) self.view.setSortingEnabled(True) spinDelegate = SpinBoxDelegate() self.view.setItemDelegateForColumn(1,spinDelegate) but it does't work: spinbox don't show after click and checkbox can't be clicked and is aligned to left Any help?

    Read the article

  • Step math function

    - by ekapek
    Hi I need function which returns: for any number from range = result [0.001,0.01) => 0.01 [0.01,0.1) => 0.1 [0.1,1) => 1 [1,10) => 10 [10,100) => 100 etc. My first idea was to use if, but this the worst way. Is there a simple solution?

    Read the article

  • Wait until user press enter in textbox in another form and return value

    - by ekapek
    Hello, I am new to C# and I'm trying to do sth like this: myList = list of 1000+ string values; 1.StartNewThreads(50); //50 is the numbers of new threads 2.DoSth1(next value from myList); 3.DoSth2(); 4. var value = { ShowNewImageForm(); //show only if not another ImageForm is displayed if another is show - wait WaitUntilUserPressEnterInTextBox(); ReturnValueFormTextbox(); } 5.DoSth3(); 6.StartNewThread(); For now I have: foreach(String s in myList ) { DoSth1(s); DoSth2(); DoSth3(); } And now I'm looking for ideas to points 1,3,6 Can You suggest me how to resolve this? How to start 50 threads How to get value from textbox in another form when user press enter

    Read the article

  • How to replace {tag_INDEX} with array[INDEX] element

    - by ekapek
    Hi, I have string like this; "String {tag_0} text {tag_2} and {tag_1}" Now i need to replace all {tag_INDEX} with elements from array $myArray = array('a','b','c'); so after replacement it should looks like: "String a text c and b" What is the best way to do this? I'm trying with preg_replace and preg_replace_callback but without any good results

    Read the article

1