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
15
votes
3 answers

Qt, How do I change the text color of one item of a QComboBox? (C++)

I cannot figure out how to change the text color of one particular item of a QComboBox. I was able to change the Background color of an item: comboBox->setItemData(i, Qt::green, Qt::BackgroundRole); (Qt::ForegroundRole had no effect at all, Qt 4.6,…
Linoliumz
  • 2,381
  • 3
  • 28
  • 35
14
votes
2 answers

How to set the default item of a QComboBox

In my function I have dictionary with empty values: self.items = { 'Maya Executable': '', 'Render': '', 'Mayapy Interpreter': '', 'imgcvt': '', 'IMConvert': '', } How should I set "Maya Executable" (i.e. the 0th key) as the QComboBox's default item…
user1176501
13
votes
6 answers

How do I Filter the PyQt QCombobox Items based on the text input?

I need a QCombox which Items are filtered based on the text input. If I set the QCombobox editable, the user can insert text and the QCompleter is automatically created. But the items are not filtered and I don’t want the user to add new Items. Is…
Tammo B.
  • 305
  • 1
  • 5
  • 9
13
votes
2 answers

Show tooltip when the user selects item in QComboBox

I want to show the tooltip with the text and the time when user selects the item in list view (hovers the mouse on the item in the list view) of QCombobox. I'm using a custom QComboBox with QItemDelegate.
Wagmare
  • 1,354
  • 1
  • 24
  • 58
13
votes
4 answers

How to make QComboBox popup upwards?

My QComboBox derived class is contained in a QGraphicsScene at the bottom end of the (visible) screen - but it pops up downwards, thus out of view. How is it possible to force the popup to open upwards, not downwards? I've tried re-implementing…
user1319422
  • 271
  • 2
  • 7
12
votes
4 answers

Rounded QComboBox without square box behind

I'm styling a QComboBox in Qt. It is rounded how the figure shows. The problem is that is shows a strange square box behind the rounded border. Can someone tell me what this box is and how to make it invisible? By the way, I'd like to take the…
jsidera
  • 1,791
  • 1
  • 17
  • 19
11
votes
4 answers

Qt How to disable mouse scrolling of QComboBox?

I have some embedded QComboBox in a QTableView. To make them show by default I made those indexes "persistent editor". But now every time I do a mouse scroll on top them they break my current table selection. So basically how can I disable mouse…
Alberto Toglia
  • 381
  • 1
  • 5
  • 17
11
votes
3 answers

Get the Contents of a QComboBox

I need to get an QStringList or an array containing all QStrings in a QComboBox. I can't find a QComboBox method that does this, in fact I can't even find a QAbstractItemModel method that does this. Is this really my only option: std::vector<…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
10
votes
1 answer

QStandardItem + QComboBox

I am trying to put a QComboBox into a QStandardItem to be used in a QStandardItemModel. I have been looking around and I cannot find an answer, any ideas?
Tom Leese
  • 19,309
  • 12
  • 45
  • 70
10
votes
3 answers

QComboBox AbstractItemView::item

Is there a way I could increase the height of the items, which are listed in a QComboBox control ? I tried following as suggested here in QTDevNet forums but with no luck QComboBox QAbstractItemView::item {margin-top: 3px;} I also tried this, still…
warunanc
  • 2,221
  • 1
  • 23
  • 40
9
votes
1 answer

How can I get all images from a qrc file?

I want to get all images from my qrc file and pass them to a ComboBox. Don't know what to say more. It's a very basic task I think but I can't find a solution.
yokmp
  • 145
  • 2
  • 10
9
votes
3 answers

QComboBox drop-down list - set selected item style

Is it possible to set selected item style (Qt style sheet) of the QComboBox drop-down list?
Sergey Vlasov
  • 111
  • 1
  • 1
  • 3
9
votes
1 answer

Get previous and newly selected item on activation in QComboBox

In my program some comboboxes (QComboBox) were used to make several settings. Sometimes its necessary not only to know the item the user selected but also the item which was selected previously in the combobox. Well, transferring the new selection…
Bastian
  • 113
  • 1
  • 8
9
votes
3 answers

How to use Model for QCombobox

I want to use QCombobox as a the Combobox of Swing in Java. So i need to use Model for holding my object. How can i hold my object in QCombobox. (I think that I should hold data in Model because QCombobox was designed according to MVC Pattern…
ibrahimyilmaz
  • 18,331
  • 13
  • 61
  • 80
9
votes
2 answers

"QComboBox Pop-up" expanding and QtWebkit

In Firefox/Chrome/InternetExplorer/Safari/Opera pop-ups from the combobox expand as the content, see Firefox picture: QComboBox pop-up does not expand the content. Pop-ups are limited by the size of QComboBox, see QWebView picture: So I…
Protomen
  • 9,471
  • 9
  • 57
  • 124
1
2
3
48 49