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
3
votes
1 answer

How to link two comboboxes in a table of multiple comboboxes?

I am trying to link the value of combobox in column 1 with the box in column 3. On change of value in column 1 the values in the dropdown combo box need to change to a new set. On click of the button, a new row is to be added with similar combobox…
Kevin_ALA
  • 233
  • 2
  • 11
3
votes
2 answers

Sending the current displayed index of item in QComboBox at start up

Using signal and slots method to get index and text of selected items in QcomboBox is well known. The code below is an illustration of that. But how can I tell my code to recieve and send the first display item at startup, Methods like Activated,…
Pavel.D
  • 561
  • 1
  • 15
  • 41
3
votes
1 answer

How can I get itemdata from qcombobox?

I have a problem when I clicked in a QtWidgets.QPushButton to show the itemData from a QtWidgets.QComboBox. I fill my ComboBox with this code: self.comboBox.addItem("Sandro",1) self.comboBox.addItem("Daniel",2) self.comboBox.addItem("Pedro",3) It…
GSandro_Strongs
  • 773
  • 3
  • 11
  • 24
3
votes
2 answers

How to know when down-arrow of Combo box is clicked?

I have a ComboBox and set it to be edited. QComboBox *myCombo = new QComboBox(this); myCombo->setEditable(true); myCombo->setStyleSheet("QComboBox::down-arrow{image: url(:/bulb.png);}"); myCombo->setCursor( QCursor( Qt::PointingHandCursor ) ); So…
songvan
  • 369
  • 5
  • 21
3
votes
1 answer

Qml ComboBox with TextField in Popup

I have created a custom ComboBox that uses a ListView with a TextField in the footer, that's used to dynamically add options to the ComboBox. The problem is, that as soon as the popup loses focus (so when the TextField receives focus), the popup…
Johannes Stricker
  • 1,701
  • 13
  • 23
3
votes
1 answer

How can i change the font size of the checkbox Name

Here is my code, i want to change font size of the checkbox name and increase the boarded size of the comboBOx, i tried like this but i am not getting the output properly.Can you please guide me how to change the size of the font import sys from…
raghava
  • 167
  • 2
  • 9
3
votes
2 answers

How to add Multiline text(textWrap) items in QComboBox

I have long text items in QComboBox, and I want to display complete text of items in multiple lines. What should I do. Thank you. Currently it puts ... between the start and end of text.
Oli
  • 1,313
  • 14
  • 31
3
votes
2 answers

How to add a scrollbar to a Qcombobox

I use python, and qt5, and qt designer. I want to add a scroll bar to the combo box. Any way to add a scrollbar using style-sheet? Other ways are also good. This is the style-sheet currently used in the combo box. QComboBox { combobox-popup:…
semikim
  • 123
  • 1
  • 9
3
votes
1 answer

PyQt5 ComboBox - how do I set the color of CurrentText without affecting the dropdown list?

The following snippet correctly sets the colors of individual entries in the ComboBox dropdown list. However, when an item is selected and transferred to the CurrentText field, all of the entries in the dropdown change to the color of CurrentText. …
OregonJim
  • 326
  • 2
  • 10
3
votes
1 answer

QML ComboBox Popup Issue

I have used so many combo boxes recently but there is an issue in the popup of a particular ComboBox which I am not able to find the exact problem following is the code: import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls…
pra7
  • 834
  • 2
  • 21
  • 50
3
votes
1 answer

How to make the text of a QComboBox bold, but not the list items?

We have a longstanding convention in our UI that items are shown in bold when they have been changed but the change is not yet committed. Strangely, until now we haven't used any combo boxes, but I have a use for one now and need to implement this…
Pete
  • 133
  • 4
3
votes
1 answer

How to fill a QComboBox with elements from a CSV file

I have a combobox on a QTDesigner QDialog form that I would like to fill with a the contents of a column in a CSV file. I invoke the call for the combo box and have the function built to pull the values from the CSV, but the combo box will not…
BTBean
  • 43
  • 5
3
votes
0 answers

QComboBox with only a icon on the toolbar, how?

I would like to make a combobox with QT and want to set it on the toolbar. User should see on the Toolbar only icons, so this comboBox should show only the icon of an item on the toolbar. But after the click on it, it pop up the sub-menu, which…
jung
  • 557
  • 2
  • 4
  • 16
3
votes
1 answer

Always show a QComboBox in a cell of a QTableView

I have a QTableView with an associated model. I want to have a QComboBox in each cell of the third column. I used a QItemDelegate as shown in this page : https://wiki.qt.io/Combo_Boxes_in_Item_Views. It works but the combo box is only shown after…
bobombe
  • 53
  • 1
  • 5
3
votes
2 answers

Qcombobox in PyQt, How could I set the options in one combo box which depends on the choice of other combo box?

For example, the first combo box with option A and option B. The second combo box contains option 1,2,3,4,5 if I select option A in 1st combo box. The second combo box contains option a,b,c,d,e if I select option B in 1st combo box. How could I do…
Kester
  • 283
  • 2
  • 5
  • 10