![](/rp/kFAqShRrnkQMbH6NYLBYoJ3lq9s.png)
How can I get the selected VALUE out of a QCombobox?
It seems you need to do combobox->itemData(combobox->currentIndex()) if you want to get the current data of the QComboBox. If you are using your own class derived from QComboBox, you can add a currentData() function.
qt - QComboBox Actions Tutorial? - Stack Overflow
2016年7月22日 · When adding items to a QComboBox you can link custom user data to your item in the form of a QVariant (see QComboBox::addItem). You can then access this user data by calling QComboBox::itemData. In your case you can set the user data of each ComboBox item to be a pointer to a QAction, which can then be accessed via QComboBox::itemData. For example:
QT - How to get SIGNAL "currentIndexChanged" from …
I want to get QString text from selected QComboBox. When I selected an index on a QComboBox, I want to get QString from the selected index, after I clicked the desired index on a QcomboBox. I have researched about this, Qt QCombobox currentIndexChanged signal; but have not found a way to solve it,
QComboBox - How to set hint text on combo box - Stack Overflow
2015年9月29日 · For newer versions of Qt try QComboBox::setPlaceholderText().. I happened to be working with an older version of Qt (5.11.3) on a Raspberry Pi and needed different solution.
qt - How to add a string to QCombobox - Stack Overflow
2013年2月1日 · Don't use dynamic memory allocation with QString.QString handles memory management for the string internally - if you allocate the memory for the QString object yourself, you also need to take care of releasing the memory.
How can I add item data to QComboBox from Qt Designer/.ui file
2016年2月2日 · I need to map the items in the combo box to strings (which are distinct from the displayed strings). The best idea I've come up for it is to use the QComboBox::itemData function to get the needed string from the selected item, but I'm having trouble adding the associated strings to the items. I've looked all over the designer and have not yet ...
How to use QComboBox as delegate with QTableView
2015年1月20日 · Here is the attempt to substitute a QComboBox with QToolButton linked to QMenu and QActions. The look and feel is about the same as QComboBox with an additional feature of having an ability to set multiple QActions checked (currently it is not possible to have multiple combo box's items checked).
Qt - How to change background from editable QComboBox?
2016年11月17日 · Previous line get the reference to the QLineEdit which is part of the QComboBox widget and applies the style sheet to it, not to the combobox. I don't know if this could also work, if you want to try it and give a feedback.. YourCombobox->setStyleSheet("QLineEdit {background: green;}");
QComboBox - set selected item based on the item's data
You can also have a look at the method findText(const QString & text) from QComboBox; it returns the index of the element which contains the given text, (-1 if not found). The advantage of using this method is that you don't need to set the second parameter when you add an item. Here is a little example :
get - Getting all items of QComboBox - Stack Overflow
2014年8月20日 · I have A LOT of QComboBoxes, and at a certain point, I need to fetch every item of a particular QComboBox to iterate through. Although I could just have a list of items that correspond to the items in the QComboBox, I'd rather get them straight from the widget itself (there are a huge amount of QComboBoxes with many items each).