How can I get the selected VALUE out of a QCombobox?

qcombobox get selected item python
qcombobox::activated example
clear qcombobox
qcombobox example
qcombobox model
qcombobox get items
qcombobox set index
python qcombobox get current text

In Qt, I can get the selected text of a QComboBox by using the combobox->currentText() method. How can I get the selected value?

I searched for help but I couldn't find a method currentData() which I expected to find. I could only find combobox->currentIndex()

Is there a smarter way to do it other than combobox->itemData(combobox->currentIndex())?

Update: This is no longer necessary as of Qt 5. A currentData() method has been added http://doc.qt.io/qt-5/qcombobox.html#currentData-prop


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.

access selected value of QcomboBox, When I was writing my programs on C# 2008, there have been many ways to get the current value of the ComboBox. In Qt, I create QComboBox� 81. 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. share. Share a link to this answer.


This one can get the text of current index:

QString cb = cbChoice ->currentText();

QComboBox: how to get selected value?, I set a QcomboBox in gui widget and ,I add item for(int i = 1; i < 31; i++) { ui-> combo->addItem(QString::number(i)); } and in QComboBox slot I� I just found out that QComboBox has also findText() method, which is the very thing I wanted to. :) – Karen Tsirunyan Oct 17 '13 at 14:59 @KarenTsirunyan, I proposed three different ways to get the same result - you can use either of them. – vahancho Oct 17 '13 at 15:01


you can set QVariant data for all items, then you can get the value when you need it.

there is an example code for this situation:

ui.comboBoxSheetSize->addItem("128 m", QVariant(128));
ui.comboBoxSheetSize->addItem("256 m", QVariant(256));
ui.comboBoxSheetSize->addItem("512 m", QVariant(512));
ui.comboBoxSheetSize->addItem("1024 m", QVariant(1024));

...

void Page::onComboSheetSizeChanged( int index )
{
 int value = ui.comboBoxSheetSize->itemData(index).toInt();
}

by the way, i think i misunderstood your question. i think the way you get data is smart enough?

access selected value of QcomboBox problem, A combobox is a selection widget that displays the current item, and can pop up or a combo box in which no current item is set, this property has a value of -1. QComboBox uses the model/view framework for its popup list and to store its items. By default a QStandardItemModel stores the items and a QListView subclass displays the popuplist. You can access the model and view directly (with model() and view()), but QComboBox also provides functions to set and get item data (e.g., setItemData() and


The member function QComboBox::currentData has been added since this question was asked, see this commit

QComboBox Class, PyQt5 – Getting the current index of selected item in ComboBox Inside the action get the index of current item selected in combo box with the help of currentIndex method and first_page Python – Maximum record value key in dictionary. A QComboBox object presents a dropdown list of items to select from. It takes minimum screen space on the form required to display only the currently selected item. A Combo box can be set to be editable; it can also store pixmap objects. The following methods are commonly used − Given below are the most commonly used methods of QComboBox.


I had same issue

I have solved by

value = self.comboBox.currentText()
print value

PyQt5, In this case you set the ComboBox.Items = Accounts and then ComboBox. Selected.AccountID will be the value you're looking for. Alternatively, you could assign� Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the option is selected, but the problem is that when the user clicks run, the contents of several of these comboboxes need to be taken into account.


Solved: Get all selected items from combobox, Learn about Selection support in Syncfusion Windows Forms ComboBox Value of the selected item can be retrieved by using the SelectedValue property. I a learning python programming and selected PyQt5 to use for my GUI. I have created a test form just to get the feel of python and I want to connect functions from a module file called 'mymods' to each widget. How can i pull say the selected text or item index from a combobox from my test form using the mymods.py file? test.py:


Selection in Windows Forms ComboBox control, Bind the KendoReact ComboBox to data and render the selected option in React projects. A combobox can be populated using the insert functions, insertItem () and insertItems () for example. Items can be changed with setItemText (). An item can be removed with removeItem () and all items can be removed with clear ().


React ComboBox Component & Data and Value Binding, Unzip the project and open the first header file in the Projucer. Each of these text strings is associated with an ID number (an int value). retrieving the currently selected ID using the ComboBox::getSelectedId() function; or; requesting the� PyQt combobox. You can have a listbox, selectbox or combobox with QComboBox.To use this widget, import QComboBox from PyQt5.QtWidgets. Typically you’d see this widget when a user needs to choose from a select number of items, like country or contract.