Search Results

Search found 15 results on 1 pages for 'qcombobox'.

Page 1/1 | 1 

  • Key/Value pyqt QComboBox

    - by Danilo
    I want to use a QComboBox with the "keys" and "values" from a tuple similar to the ones used in a django models. For example I have the following structure for a person's sex. SEX_CHOICES = (('M', 'Male'), ('F', 'Female')) The first item of the tuple contains the code of the sex that is stored in the database, and the second one the text that I want to display in the QComboBox as an item. Is there a way in wich I could set the QComboBox value as M and it displays Male. An also when the user select the element Male I could get the selected value as M. Thanks

    Read the article

  • How to get the row number of the QComboBox in QTableWidget

    - by dreamxiuhuishan
    Here is the code, but it dos not work. Who can create the code. Thanks very much! void add() { QComboBox *ziduan = new QComboBox; ziduan->addItem("??","nd"); int row =0; int col =1; QSignalMapper* signalMapper = new QSignalMapper(this); connect(ziduan, SIGNAL(currentIndexChanged(int)), signalMapper, SLOT(map())); signalMapper->setMapping(ziduan, QString("%1-%2").arg(row).arg(col)); connect(signalMapper, SIGNAL(mapped(const QString &)),this, SIGNAL(changeZiduan(const QString &))); } void sqlGenerator::changeZiduan(const QString &position) { QStringList coordinates = position.split("-"); int row = coordinates[0].toInt(); int col = coordinates[1].toInt(); }

    Read the article

  • Python PyQT4 - Adding an unknown number of QComboBox widgets to QGridLayout

    - by ZZ
    Hi all, I want to retrieve a list of people's names from a queue and, for each person, place a checkbox with their name to a QGridLayout using the addWidget() function. I can successfully place the items in a QListView, but they just write over the top of each other rather than creating a new row. Does anyone have any thoughts on how I could fix this? self.chk_People = QtGui.QListView() items = self.jobQueue.getPeopleOffQueue() for item in items: QtGui.QCheckBox('%s' % item, self.chk_People) self.jobQueue.getPeopleOffQueue() would return something like ['Bob', 'Sally', 'Jimmy'] if that helps.

    Read the article

  • 'C++ object destroyed' in QComboBox descendant editor in delegate

    - by Max
    Hi, all! I have modified combobox to hold colors, using QtColorCombo (http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Widgets/qtcolorcombobox) as howto for the 'more...' button implementation details. It works fine in C++ and in PyQt on linux, but I get 'underlying C++ object was destroyed' when use this control in PyQt on Windows. It seels like the error happens when: ... # in constructor: self.activated.connect(self._emitActivatedColor) ... def _emitActivatedColor(self, index): if self._colorDialogEnabled and index == self.colorCount(): print '!!!!!!!!! QtGui.QColorDialog.getColor()' c = QtGui.QColorDialog.getColor() # <----- :( delegate fires 'closeEditor' print '!!!!!!!!! ' + c.name() if c.isValid(): self._numUserColors += 1 #at the next line currentColor() tries to access C++ layer and fails self.addColor(c, self.currentColor().name()) self.setCurrentIndex(index) ... Maybe console output will help. I've overridden event() in editor and got: ... MouseButtonRelease FocusOut Leave Paint Enter Leave FocusIn !!!!!!!!! QtGui.QColorDialog.getColor() WindowBlocked Paint WindowDeactivate !!!!!!!!! 'CloseEditor' fires! Hide HideToParent FocusOut DeferredDelete !!!!!!!!! #6e6eff ... Can someone explain, why there is such a different behaviour in the different environments, and maybe give a workaround to fix this. Here is minimal example: http://docs.google.com/Doc?docid=0Aa0otNVdbWrrZDdxYnF3NV80Y20yam1nZHM&hl=en

    Read the article

  • QConnect find no such slot on QCombobox by Qt Creater

    - by user2534154
    I create a window inherit from QWidget I set grid layout to that Window I make a function called handleHeroChange(int index) in public slot inside that window I add a Qcombobox to call that function handleHeroChange(int index). Qtcreator keep telling: QObject::connect: No such slot QWidget::handleHeroChange(int) in ../Testing/Window.cpp:92 Why did i do wrong? THE CODE: Window::Window(QWidget *parent) : QWidget(parent) { QGridLayout *grid = new QGridLayout(this); QComboBox *comboHeroClass = new QComboBox(); comboHeroClass->addItem("Witcher"); comboHeroClass->addItem("Maurander"); comboHeroClass->setCurrentIndex(1); grid->addWidget(comboHeroClass, 2,3,1,1); QComboBox::connect(comboHeroClass, SIGNAL(currentIndexChanged(int)),this, SLOT(handleHeroChange(int))); } void Window::handleHeroChange(int index){ QPixmap myImage; if(index == 0){ }else if(index == 1){ } }

    Read the article

  • How to make QCombobox painting item delegate for it's current Item? (Qt 4)

    - by r4nj33t
    QCombobox set Item delegate not painting for current Item.. I am trying to create a combo box showing different line types (Solid, Dotted, Dash etc). Currently i am setting item delegate for its content so as to draw/paint line type instead of displaying names. All line types are drawing currectly but as soon as i am selecting any line type from the combobox, the current index of combo box is displaying just the line name and not painting it. How can i make it paint the selected line type on the current combo box index?

    Read the article

  • breakpoint inside QComboBox subclass not working

    - by yan bellavance
    I have subclassed QComboBox to customize it for special needs. The subclass is used to promote QComboBoxes in a ui file from QtDesigner. Everything works except that when I put a break point in a slot, the program does not stop at the breakpoint. I do however know that it is being called from the result it generates. I checked other slots in my program and they work fine with breakpoints. Doing a clean and rebuild all did not fix it. What could be causing this and is there anything I can do about it? The slot in question is the only one in the subclass and is called "do_indexChanged()". You can find the slot on line 37 of the class header below and the signal-slot connection on line 10 of the class source file. CLASS HEADER: #ifndef WVQCOMBOBOX_H #define WVQCOMBOBOX_H #include <QWidget> #include <QObject> #include <QComboBox> #include <QVariant> class wvQComboBox : public QComboBox { Q_OBJECT //Q_PROPERTY(bool writeEnable READ writeEnable WRITE setWriteEnable) public: explicit wvQComboBox(QWidget *parent = 0); bool writeEnable() { return this->property("writeEnable").toBool(); } void setWriteEnable(const bool & writeEnable){ this->setProperty("writeEnable",writeEnable); } bool newValReady() { return this->property("newValReady").toBool(); } void setNewValReady(const bool & newValReady){ this->setProperty("newValReady",newValReady); } QString getNewVal(); int getNewValIndex(); int oldVal; //comboBox Index before user edit began private slots: void do_indexChanged(){ this->setWriteEnable(true); if(oldVal!=currentIndex()){ this->setNewValReady(true); oldVal=currentIndex(); } } protected: void focusInEvent ( QFocusEvent * event ); //void focusOutEvent ( QFocusEvent * event );//dont need because of currentIndexChanged(int) }; #endif // WVQCOMBOBOX_H #include "wvqcombobox.h" wvQComboBox::wvQComboBox(QWidget *parent) : QComboBox(parent) { this->setWriteEnable(true); this->setNewValReady(false); oldVal=this->currentIndex(); connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(do_indexChanged())); } void wvQComboBox::focusInEvent ( QFocusEvent * event ) { this->setWriteEnable(false); oldVal=this->currentIndex(); } QString wvQComboBox::getNewVal(){ setNewValReady(false); return this->currentText(); } int wvQComboBox::getNewValIndex(){ setNewValReady(false); return this->currentIndex(); }

    Read the article

  • QComboBox returns None Type . How to get Current Data ?

    - by vettipayyan
    I've implemented 2 QComboBoxes with one having items manually inserted every time and another one having items inserted with a list (I'm using Python ) But when i attempt to get the current value of Combobox , it returns None . I proceeded as specified in this question : I referred this i have provided wat i've coded ."command" and "option" are QComboBoxes ( Pardon me for bad style) Is there any mistake in Indexes ? self.command.insertItem(1,'Convert') self.command.insertItem(2,'Compose') self.command.insertItem(3,'Animate') self.option.insertItems(268,list) and retrieval : self.selected_com=self.command.itemData(self.command.currentIndex()) self.selected_opt=self.option.itemData(self.option.currentIndex())

    Read the article

  • How can I make a Qt widget ignore style sheets set on parent widgets?

    - by Hisham Abboud
    When adding a QComboBox control in Qt Designer, I get a terrible looking, non-native control, see: http://curiouschap.com/wp-content/uploads/2010/05/stack_qcombobox_question.png [as a newbie, SO wouldn't let me insert the image] On digging further, it turns out that two of the parent controls, QParentWindow and QStackedWidget, have style sheets that QComboBox is inheriting. If I delete the custom styles, then I get a native QComboBox like the one on the left. How can I have QComboBox (and widgets generally) NOT inherit parent styles? Or, how can I create a style for, say, QParentWindow, and do it so that it's local only and does not cascade?

    Read the article

  • Custom editor in QAbstractTableModel

    - by Martin Beckett
    Does anyone have an example of using a QWidget as an editor in a QAbstractTableModel? I have a column which when edited should create a QCombobox with the list of choices. The docs seem to suggest I need to write a QAbstractItemDelegate and a custom paint function but that seems overkill to simply pop-up a standard QCombobox in Qt::EditRole. Note - the combo box contents are the same for every row and it only needs to be shown when somebody clicks in the cell. I know this should be simple but I can't get it to work. It's easy for a QTableWidget based table - but I need it for a very large data table.

    Read the article

  • QUiLoader and ignored dynamic properties

    - by Googie
    I'm loading the .ui file, where one of the widgets (QComboBox) has a dynamic property (http://qt-project.org/doc/qt-5/properties.html#dynamic-properties). The UI file looks like this: <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>PopulateScriptConfig</class> <widget class="QWidget" name="PopulateScriptConfig"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> <widget class="QGroupBox" name="langGroup"> <property name="title"> <string>Language</string> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> <widget class="QComboBox" name="langCombo"> <property name="ScriptingLangCombo" stdset="0"> <bool>true</bool> </property> </widget> </item> </layout> </widget> </item> <item> <widget class="QGroupBox" name="codeGroup"> <property name="title"> <string>Implementation</string> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> <widget class="QPlainTextEdit" name="codeEdit"/> </item> </layout> </widget> </item> </layout> </widget> <resources/> <connections/> </ui> The important part is: <widget class="QComboBox" name="langCombo"> <property name="ScriptingLangCombo" stdset="0"> <bool>true</bool> </property> </widget> I'm loading the file with QUiLoader::load(). Note, that I have extended the QUiLoader class, but only to access createWidget() method, where I can query each widget like this: QWidget* UiLoader::createWidget(const QString& className, QWidget* parent, const QString& name) { QWidget* w = QUiLoader::createWidget(className, parent, name); qDebug() << w->dynamicPropertyNames(); return w; } As a result I see empty list displayed, so it seems like the dynamic property is completly ignored. Any ideas? P.S. I've made sure that I load correct file. 3 times.

    Read the article

  • How to support comparisons for QVariant objects containing a custom type?

    - by Tyler McHenry
    According to the Qt documentation, QVariant::operator== does not work as one might expect if the variant contains a custom type: bool QVariant::operator== ( const QVariant & v ) const Compares this QVariant with v and returns true if they are equal; otherwise returns false. In the case of custom types, their equalness operators are not called. Instead the values' addresses are compared. How are you supposed to get this to behave meaningfully for your custom types? In my case, I'm storing an enumerated value in a QVariant, e.g. In a header: enum MyEnum { Foo, Bar }; Q_DECLARE_METATYPE(MyEnum); Somewhere in a function: QVariant var1 = QVariant::fromValue<MyEnum>(Foo); QVariant var2 = QVariant::fromValue<MyEnum>(Foo); assert(var1 == var2); // Fails! What do I need to do differently in order for this assertion to be true? I understand why it's not working -- each variant is storing a separate copy of the enumerated value, so they have different addresses. I want to know how I can change my approach to storing these values in variants so that either this is not an issue, or so that they do both reference the same underlying variable. It don't think it's possible for me to get around needing equality comparisons to work. The context is that I am using this enumeration as the UserData in items in a QComboBox and I want to be able to use QComboBox::findData to locate the item index corresponding to a particular enumerated value.

    Read the article

  • pyqt QTreeWidget setItemWidget dissapears after drag/drop

    - by mleep
    I'm trying to keep a widget put into a QTreeWidgetItem after a reparent (drag and drop) using QTreeWidget.setItemWidget() But the result, if you compile the following code - is that the widget inside the QTreeWidgetItem disappears. Any idea why? What code would fix this (repopulate the QTreeWidgetItem with the widget I guess?) from PyQt4.QtCore import * from PyQt4.QtGui import * class InlineEditor (QWidget): _MUTE = 'MUTE' def __init__ (self, parent): QWidget.__init__ (self, parent) self.setAutoFillBackground (True) lo = QHBoxLayout() lo.setSpacing(4) self._cbFoo = QComboBox() for x in ["ABC", "DEF", "GHI", "JKL"]: self._cbFoo.addItem(x) self._leBar = QLineEdit('', self) lo.addWidget (self._cbFoo, 3) lo.addSpacing (5) lo.addWidget (QLabel ( 'Bar:')) lo.addWidget (self._leBar, 3) lo.addStretch (5) self.setLayout (lo) class Form (QDialog): def __init__(self,parent=None): QDialog.__init__(self, parent) grid = QGridLayout () tree = QTreeWidget () # Here is the issue? tree.setDragDropMode(QAbstractItemView.InternalMove) tree.setColumnCount(3) for n in range (2): i = QTreeWidgetItem (tree) # create QTreeWidget the sub i i.setText (0, "first" + str (n)) # set the text of the first 0 i.setText (1, "second") for m in range (2): j = QTreeWidgetItem(i) j.setText (0, "child first" + str (m)) #b1 = QCheckBox("push me 0", tree) # this wont work w/ drag by itself either #tree.setItemWidget (tree.topLevelItem(0).child(1), 1, b1) item = InlineEditor(tree) # deal with a combination of multiple controls tree.setItemWidget(tree.topLevelItem(0).child(1), 1, item) grid.addWidget (tree) self.setLayout (grid) app = QApplication ([]) form = Form () form.show () app.exec_ ()

    Read the article

  • How to access widgets created within functions in later function calls in Qt

    - by Inanepenguin
    So currently I have code, in C++, that creates a few QLabels, a QLineEdit, and a QCheckBox when a selection is made from a QComboBox. However, I would like to be able to access the widgets I have created in a later function to destroy them if a new selection is made from the combo box. I am able to access the objects created from using the Designer by doing ui-Object but i am not able to do that with objects created by using my own code. Can I do that some how, because I know how to work with that. In short, I would like to be able to dynamically create/destroy QWidgets based on selections made by the user. Is there a reference I should know of to do this, or any documentation? Or am I just completely going about this the wrong way? Here is the code I presently have for creating the objects: if (eventType == QString::fromStdString("Birthday")) { QLabel *label1 = new QLabel ("Celebrant: "); QLabel *label2 = new QLabel ("Surprise: "); QLineEdit *lineEdit = new QLineEdit; QCheckBox *box = new QCheckBox; ui->gridLayout->addWidget(label1,3,0,1,1, 0); ui->gridLayout->addWidget(label2,4,0,1,1,0); ui->gridLayout->addWidget(lineEdit,3,1,1,1,0); ui->gridLayout->addWidget(box,4,1,1,2,0); }

    Read the article

1