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

Run function when selecting a new item in a QComboBox

I have a QComboBox with a few items in it, and I want to run a function when the user selects a new item, different from the current one. The basic code (without including the items) is.. categories_combo =…
0
votes
1 answer

QComboBox text color doesn't change as expected

I have a simple QComboBox but I cannot figure out how to change the text color of the selected item. It stays black but it should be white. I used the color:white; properties but it seems to affect only the color of the popup item list. this is my…
Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
0
votes
1 answer

How make items in combobox appear in one selection instead of selecting them only one by one?

How do you get items that are added to qcomboBox with click of push button to appear as example: '10, 23, 56, 14, 57, ... ' instead of only having them all appear in the drop down menu and only selecting them one by one? Here is my code: def…
Viv91
  • 45
  • 2
  • 8
0
votes
1 answer

Populate QComboBox with QEnums

I've looked in multiple places and cannot seem to find anything to work for my purpose. I have this QComboBox that constantly changes (And could change after the program is completely finished). To make it easier I made an Enum list for switch…
0
votes
1 answer

How the comboBox works?

I'm a complete beginner in PyQt and I put a combo box: select = QtGui.QComboBox(self) select.addItem("San Marcos") select.addItem("San Luis") select.addItem("San Lucas") select.addItem("Rosario I") select.addItem("Rosario…
Margarita Gonzalez
  • 1,127
  • 7
  • 20
  • 39
0
votes
1 answer

How to get select item data from QComboBox populated with QSqlTableModel

I have a basic combo box populated with data from an sqlite3 database table: self.langModel = QSqlTableModel(self) self.langModel.setTable("languages") self.langModel.setSort(self.langModel.fieldIndex("label"),…
cj5
  • 785
  • 3
  • 12
  • 34
0
votes
1 answer

How do create delegate to display icon and text of QComboBox in QTreeWidget (PyQt)?

I've been having some trouble trying to display icon and text in QTreeWidget . My QTreeWidget just display text!! how use paint method for display icon and text ?Thank you very much!the Code is as following: from PyQt4 import QtGui,QtCore import…
0
votes
2 answers

QCombo box to set layer (for Python QGIS plugin)

I'm attempting to create a function to declare a variable in terms of an item chosen in a QComboBox. It's for a plugin for QGIS 2.0 and 2.2. I'm getting a "list index out of range" error, but cannot see why. I'm wondering if my…
user25976
  • 1,005
  • 4
  • 18
  • 39
0
votes
1 answer

QComboBox dynamic list of items

I have two QTableWidgets. Let's call them Tab1 and Tab2. One column of Tab1 contains QComboBoxes where their items are rows from Tab2. When elements of Tab2 are modified (added/removed/edited) I want all QComboBoxes to update. Tab1 concept LineNo…
Michał
  • 2,456
  • 4
  • 26
  • 33
0
votes
1 answer

Combobox with MySQL

I have database and i want to put data to my combobox: QSqlQueryModel *model = new QSqlQueryModel (ui->comboBox); model->setQuery ("SELECT country_name FROM Country"); ui->comboBox->setModel(model); But i don't know how to code my…
0
votes
0 answers

Strange behaviour of QCombobox::setItemData function

I was working with a simple class derived(publicly) from QComboBox and noticed a strange behaviour of setItemData function: a simple example: QFont font; font.setItalic(true); setItemData(0, font, Qt::FontRole); I was sure that this had to change…
Karen Tsirunyan
  • 1,938
  • 6
  • 19
  • 30
0
votes
1 answer

Can't use QString in a QLineEdit nor QComboBox as a parameter

I'm trying to make a function that replace the text inside a QLineEdit when the user want to revert is name to default using a QPushButton. This is where the code is getting "saved". `//Must get information in the DB lineditPlayerName = new…
Chax
  • 1,041
  • 2
  • 14
  • 36
0
votes
1 answer

QMainWindow crashes when using QComboBox

I have a problem with my application in Qt, I use a QMainWindow and try to set up 2 QComboBox like I did for other widgets but the application crashes at the setupUi : Voilà ma classe MainWindow, elle fonctionnait parfaitement et s'affichait jusqu'à…
Woute
  • 15
  • 1
  • 4
0
votes
2 answers

How to display Folders and recent items

I have 2 questions in trying to retrieve a set of data from a directory and displays it out into the ListWidget. As I am a linux user, I set my ListWidget to read my directory from Desktop in which insides contains say 5 folders and 5 misc items…
dissidia
  • 1,531
  • 3
  • 23
  • 53
0
votes
1 answer

list filtering with qcombobox and qlineedit

I have a question on how to filter items from a ListWidget via combobox selection Example, in my ListWidget, there are Yellow 01, Yellow 02, Blue 01, Red 01, Red 02 and Red 03 Whereas in my combobox, there are Yellow, Blue and Red I guess, you got…
yan
  • 631
  • 9
  • 30