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

Change Dropdown-Position of editable QCombobox

I created an editable QCombobox storing the last inputs by: QComboBox* input = new QComboBox(); input->setEditable(true); input->completer()->setCompletionMode(QCompleter::PopupCompletion); input->setMaxCount(5); Now I got 2 issues: I want to…
Kapa11
  • 311
  • 2
  • 18
3
votes
2 answers

How to specify different strings for a QComboBox's popup menu than are displayed in the box itself?

I've got a Qt/C++ app that contains a number of (non-editable) QComboBox widgets in a crowded window. The user can click on these combo-box to choose from various types of units. To keep the window width manageable, the QComboBoxes need to be as…
Jeremy Friesner
  • 70,199
  • 15
  • 131
  • 234
3
votes
2 answers

How to make QComboBox that has only one field editable?

I want to make a QComboBox that allows you to select value or enter your own value. It should work so that if you select the editable option and enter text, that will be the text for that option. If you select other and then go back to editable one,…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
3
votes
1 answer

Font size QComboBox items?

Say I fill QComboBox with a number on each line. And lines are very close vertically. How can I control vertical the distance?
Narek
  • 38,779
  • 79
  • 233
  • 389
3
votes
1 answer

Add my own object to QComboBox, Q_DECLARE_METATYPE, incomplete type 'QStaticAssertFailure'

I need to add my own objects to QComboBox instead of just QStrings. Here's my own class, I need to add its objects to combo box: #ifndef SERVICE_H #define SERVICE_H #include #include #include #include…
yak
  • 3,770
  • 19
  • 60
  • 111
3
votes
2 answers

Popup of QComboBox as QGraphicsProxyWidget obscured / intersected

I have a QGraphicsScene in which I am displaying some QGraphicsProxyWidgets, for example a QComboBox. In the initial state, everything is fine: However, once the popup portion of the combobox is shown, it is not on top of the scene, but behind the…
Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
3
votes
1 answer

QCombobox works very slow with QSqlQueryModel with large model

I have few comboboxes with very dig data sets within ~ 100K rows and more. I tried it with QStandardItemModel - works fast enough if model is preloaded, also model loading takes few seconds if performed in separate thread. Tried comboboxes with…
Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
3
votes
1 answer

populating combo box with folders on disk using QFileSystemModel

Hi I have written this basic code trying to populate folders underneath the /Users/ directory, but I don't know what I am missing its not populating. import sys from PyQt4 import QtGui from PyQt4 import QtCore class MyWindow(QtGui.QWidget): …
Ciasto piekarz
  • 7,853
  • 18
  • 101
  • 197
3
votes
2 answers

Does QComboBox::count() include separators in the count?

If I do: QComboBox *cb = ...; cb->clear(); cb->addItem(...); cb->insertSeparator(1); cb->addItem(...); Is cb->count() going to return 2 or 3?
Claudiu
  • 224,032
  • 165
  • 485
  • 680
3
votes
2 answers

A QLineEdit/QComboBox search that ignores diacritics

I have an application where people can enter names of places in a form. This being Europe, we have to deal with names that includes diacritics like Orléans, Köln, Liège, Châteauroux. When people enter names I want them to be able to type characters…
JvO
  • 3,036
  • 2
  • 17
  • 32
3
votes
1 answer

QT Combo Box of Line Pattern

i want to make a line pattern combo box in Qt same as it is shown in the picture , please tell me is it possible to make a combo box in Qt like shown in the picture. Any help would be appreciated Regards
3
votes
2 answers

How to set QComboBox background color on drop down state?

I can change QComboBox color like this: QPalette palette = ui->selectSource->palette(); palette.setColor(QPalette::Active, QPalette::Button, Qt::white); palette.setColor(QPalette::Inactive, QPalette::Button,…
user2440074
3
votes
1 answer

Add QListView to QComboBox for proper display of scrollbar

I have a combobox with long texts to fit into the combobox, so when I drop down, they are displayed like "very_long...long_text". When I do: QAbstractItemView* view = myCombo->view(); view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn ); The…
Terrordrone
  • 139
  • 2
  • 12
3
votes
2 answers

QComboBox Array Access

I'd like to be able to access the values in my QComboBox without having to loop over the contents using itemText. for( auto i = 0u; i < myQComboBox->count(); i++ ) { result[i] = myQComboBox->itemText( i ); } Is there a way that I can get to…
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
3
votes
2 answers

How to create autocomplete combobox in PyQt4?

How to create autocomplete combobox in PyQt4? Example what I want: http://jqueryui.com/autocomplete/#combobox
user7172
  • 874
  • 4
  • 16
  • 31