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
9
votes
2 answers

Disabling QComboBox in pyqt

Is it possible to disable QComboBox in pyqt like we can do it in Win Forms(C#) since I could not find any option in the QComboBox manual. I want to enable QcomboBox only when admin logins.
prattom
  • 1,625
  • 11
  • 42
  • 67
9
votes
1 answer

PyQt QComboBox setting number of visible items in dropdown

I'm working on an application in PyQt that takes an object dictionary and allows you to plot the variables streaming from a robot in real time. One of the things I'm working on to enable this is a drop down menu. Unfortunately, we have a couple…
Bradley Powers
  • 717
  • 7
  • 19
8
votes
2 answers

How can I add a QComboBox to the Main Toolbar in Qt Creator

I am writing a Text Editor on Qt Creator. I have a QPlainTextEdit as the central widget, and I want all the font-controlling tools in the main toolbar automatically added to all QMainWindow projects. When I try to drag and drop a QComboBox on to the…
W.K.S
  • 9,787
  • 15
  • 75
  • 122
8
votes
3 answers

Checkboxes in a Combobox using PyQt

I need to implement a drop down list that contains CheckBoxes, much like having the entries in a ComboBox being CheckBoxes. But QComboBox doesn't accept QCheckBox as its member and I couldn't find any alternate solution. I found an implementation in…
Abdul Muneer
  • 81
  • 1
  • 1
  • 2
8
votes
2 answers

PyQt (or just QT). How to get QComboBox to fire a signal whenever it is set to a value (even if unchanged)

I am using PyQt4, but this is general enough that it could just apply to QT. I have a series of QComboBoxes that I fill from left to right (i.e. selecting an item in the leftmost will populate the next one. Selecting an item in that one will…
bvz
  • 869
  • 3
  • 13
  • 25
8
votes
3 answers

QComboBox click event

I have been trying to get a QComboBox in PyQt5 to become populated from a database table. The problem is trying to find a method that recognizes a click event on it. In my GUI, my combo-box is initially empty, but upon clicking on it I wish for the…
Palu
  • 668
  • 3
  • 11
  • 26
8
votes
2 answers

Grouped QComboBox

Could you show me a simple example of how to make this grouped combobox in Qt?
Šerg
  • 793
  • 5
  • 18
8
votes
2 answers

PyQt Enable/Disable elements in a QComboBox

I have a QComboBox that list all Windows' drive letters and let the user choose among them. During the execution, we need to enable or disable some of the letters (without removing them). Here is the basic code : all_letters = ["{}:".format(chr(i))…
samb
  • 1,713
  • 4
  • 22
  • 31
8
votes
5 answers

QComboBox style for choosen item in drop-down list

I want to style the highlighting of chosen item in drop-down of combobox. The difference to other questions is that I do not want to style "selected" item (hovered over), but to style the already chosen item. The default is some sort of tick which…
nayana
  • 3,787
  • 3
  • 20
  • 51
8
votes
4 answers

Qt - Set display text of non-editable QComboBox

I would like to set the text of a QComboBox to some custom text (that is not in the QComboBox's list), without adding this text as an item of the QComboBox. This behaviour is achievable on an editable QComboBox with QComboBox::setEditText(const…
PrisonMonkeys
  • 1,199
  • 1
  • 10
  • 20
7
votes
2 answers

Pyqt prevent combobox change value

I have four combo-box boxes that in PyQT4. If user change the value in first combo-box the values from second are altered and similarly if the value in second combo-box change, that results in the change of thirds combo-box and the same case for the…
Ahsan Mukhtar
  • 629
  • 10
  • 31
7
votes
1 answer

Key/Value pyqt QComboBox

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…
Danilo
  • 79
  • 1
  • 3
7
votes
3 answers

PyQt: How to set Combobox Items be Checkable?

To keep the GUI widgets number to minimum I need to find a way to give to user a choice of pull-down menu items that could be used to filter out the displayed in a listWidget items. Let's say the listWidget lists 5 different categories of Items:…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
7
votes
1 answer

Catch mouse button pressed signal from qComboBox popup menu

I have made multi-select QComboBox. Items are checkable (every item have check box and text value). CheckBox is checked only when user click on it. What I want is to catch signal when user click on text value so I can set check box next to it…
Aleksandar
  • 3,541
  • 4
  • 34
  • 57
6
votes
2 answers

Problem in restoring floating toolbar for QMainWindow

I am seeing a problem while restoring QMainWindow state having QCombobox in floating toolbar. After restoring floating toolbar, my QCombobox is not able to get focus until i click on toolbar handle and move it. Following is gif showing problem,…
SaurabhS
  • 633
  • 1
  • 7
  • 18
1 2
3
48 49