Questions tagged [qcombobox]

QComboBox is a Qt class that implements a standard combo-box, which is a list of elements that can contract to occupy less screen space, and expand to show all of the options.

In it's "closed" view, the QComboBox displays the current selection. It can also pop-up to show all of the choices, and can as well be user-editable.

QComboBox can be operated dynamically to insert (with insertItem() and insertItems() functions), remove (removeItem()), and clear (clear()) items.

One can also get the current item's index and text.

An example of creating a QComboBox and showing it will look like this:

//creating the combobox with no parent, so it appears in a new window.
QComboBox * b = new QComboBox();
//Inserting 3 elements into it. 
b->insertItems(0, QStringList() << "item1" << "item2" << "item3");
//Showing the ComboBox.
b->show();

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

727 questions
-1
votes
1 answer

PyQt5 Python: How to go through Individual Row of Data from MySQL Query Result

I am trying to add item in a QComboBox in PyQt5 using Python. I am having problems in adding data from the SQL Query per row. cursor = cnx.cursor() query = "SELECT buyerID, lastName, firstName, middleName FROM buyer ORDER BY id DESC…
lloydyu24
  • 753
  • 1
  • 8
  • 17
-1
votes
1 answer

pyqt5 combobox.clear() causing unclear issue

I have a combobox which shows 2 values a | b these are taken from a csv file, The normal implementation works with out issue, see this post for more details: displaying two values in a pyqt5 combobox and passing those values However, I have a button…
Spatial Digger
  • 1,883
  • 1
  • 19
  • 37
-1
votes
2 answers

Adding INT values in combo box in Python

i'm basically trying to add values 1-100 in combo box but i'm unable to do so for i in range(1,100): rollno_list = [] rollno_list.append(i) combo_roll = QComboBox() combo_roll.addItems([str(rollno_list)])
-1
votes
2 answers

What's the accepted way to fill a QComboBox defined in QtQuick QML, from C++?

I want to populate a QComboBox defined in QML from my C++ code. I have seen two possible ways to do this: Define a list (as a QStringList for example) from the C++ code, and expose it as Q_ELEMENT. Then access that list from the C++, by saying…
zara
  • 109
  • 1
  • 5
-1
votes
2 answers

QComboBox doesn't display the currently selected item unless another button in the dialog is clicked

I have this QDialog: The QComboBox won't display the currently selected item unless any other button inside the dialog was clicked. Important thing to note is, that this only happens in the deployment. When I run the project in Qt it works just…
dasmanfred
  • 209
  • 2
  • 8
-1
votes
2 answers

How to remove duplicates from QcomboBox in pyqt4 python

How to remove duplicates from combobox in pyqt4 . i have tried following code but its not removing duplicates from comboBox. Code: from PyQt4 import QtCore, QtGui import sys app = QtGui.QApplication(sys.argv) w = QtGui.QWidget() w.resize(500,…
-1
votes
1 answer

How to change drop-down background color on qcombobox hover?

I need to change the drop-down button background of the QComboBox when the mouse hover on QComboBox. I dont get how to do that? If I wrote QComboBox::drop-down:hover it would be wrong because it is selector to hower ower drop-down button not ower…
AeroSun
  • 2,401
  • 2
  • 23
  • 46
-1
votes
1 answer

How to make data persistent when setData method is used

The code below creates a single QComboBox. The combo's QStandardItems are set with data_obj using setData method. Changing combo's current index triggers run method which iterates combo' and prints the data_obj which turns to Python dictionary. How…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
-1
votes
1 answer

Choose Directory from combobox and list subdirectories in textedits

I am trying to list all subdirectories which are inside a directory(which is chosen from combobox). Now I can show list of directories in combobox . I want to select one of those directory and list every sub-dirs( inside this selected dir) in…
J.YOLO
  • 41
  • 6
-1
votes
1 answer

QComboBox steal focus on popup

There have 2 Qt program. One is a normal program have QComboBox it isn't I design. I design another, after startup it hide and if keep press KEY_POWER 2 sec it show, you can press KEY_TAB/KEY_LEFT/KEY_DOWN move focus between two buttons. By the…
笼笼鸽
  • 1
  • 1
-1
votes
1 answer

QComboBox not triggered

I have this listWidget that displays a list of dogs (name - breed) . I have this comboBox that is supposed to let me choose between displaying short version (just name - breed) or detailed version (name - breed - age - weight - photograph). For…
Bryuki HK
  • 41
  • 4
-1
votes
1 answer

Correct size of QLabel and QComboBox in Qt Designer [pyqt]

I'm not an expert of pyqt and Qt Designer. I have a trivial problem that I cannot solve. Very simple, within a QScrollBar I have some labels and some checkboxes. In Qt Designer all is going right: In the code I have to interactively change the…
matteo
  • 4,683
  • 9
  • 41
  • 77
-1
votes
1 answer

QComboBox implementation

I have a list of values in a QComboBox. When the drop-down arrow is clicked, I need to update the list and display to the user for selection. How can I implement this? Which signal should I catch when the drop-down arrow is clicked?
Aham
  • 49
  • 1
  • 8
-1
votes
1 answer

QComboBox in QTreeView-cell

I want to show a QComboBox within specific cells of a QTreeView. I know I have to use an own model for it. The whole thing is already working properly with QIcons shown in the cell, but I fail doing the same with a combobox. That's what my model…
Elmi
  • 5,899
  • 15
  • 72
  • 143
-1
votes
2 answers

How to get QComboBox Item data

Instead of using .addItem("Item Name", "My Data") to populate the QComboBox I create its item first: item = QtGui.QStandardItem("Item Name") Then I set item's data: item.setData("My data") Question. How to get the data stored in Combo's Item from…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
1 2 3
48
49