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

How to make QCombobox hide popup and keep focus when a window has Escape button as shortcut key

I have a form created using Pyside2. I have a QCombobox in a form that also has a QToolbutton. The QToolbutton has a shortcut using the Escape key to close the window if triggered. When my Combobox displays its popup and I press the Escape key the…
Ongky
  • 39
  • 1
  • 4
2
votes
3 answers

Is it possible to copy QCombobox to another QCombobox

I use Qt Designer to build my UI layout. On the layout, I have a combobox named cb_fac_cd. In my code I have a function that will automatically build a combobox based on the list I'm attempting to build. I have a lot of these lists defined in the…
Andy
  • 49,085
  • 60
  • 166
  • 233
2
votes
0 answers

Tab gets stuck at QComboBox after setting the tab order for navigation

I created a form using QT (c++) consisting of different QLineEdits and QComboBox . Even after setting the tab order the tab gets stuck at the QComboBox. The Tab looks something like this .. and the tab navigation works fine for QLineEdit but gets…
hermione
  • 21
  • 3
2
votes
1 answer

QCombobox finData method always returns -1 with numpy array

I have a problem trying to get the index of some data on the combobox when a numpy array is used to add the items, while if I use a list the result is the expected. from PySide2 import QtWidgets import numpy as np app =…
Eduardo
  • 687
  • 1
  • 6
  • 24
2
votes
1 answer

QComboBox Auto Complete (QCompleter?)

I have another question with Python GUI widgets in Qt Designer. I am using Python 3.7 w/ PyQt5. I have a list of values being generated to a combo box from an SQL table. The combo box displays all of the values correctly but there are around 100…
MyOwnIssues
  • 53
  • 1
  • 6
2
votes
1 answer

Using QComboBox in QTableView properly - issues with data being set and clearing QComboBoxes

In my application im using a QTableView, QStandardItemModel and a QSortFilterProxyModel in between for filtering. The content is updated via a method for columns 1 & 2, and I want there to be a 3rd column for user to select options. I would prefer…
dree
  • 170
  • 1
  • 11
2
votes
2 answers

Using PyQT, how do you filter mousePressEvent for a QComboBox with custom list

I've got a QComboBox with a custom list object. The custom list object has a custom mousePressEvent so that when the user click on one of the circles with a +/- (a twisty), the list is expanded/collapsed. When I use the list with the combo box,…
Gary van der Merwe
  • 9,134
  • 3
  • 49
  • 80
2
votes
1 answer

How to make dynamic combobox PYQT5

I want to make a dynamic combobox, if i choose the option "Gasto" in the next combobox, I want to see for example "Agua", "Gas" etc, and if, choose "Financas", have only " Fundos de tesouraria " and " Fundos de investimento de obrigações" def…
2
votes
1 answer

Python, Qt, ComboBox, two columns?

The question is quite simple, but as far there is a problem with the answer: I'm using QT with Python and SQL. I'm getting some query data: 'select id, department from departments' I want to create combobox with two columns (id, department), which…
rsj
  • 41
  • 5
2
votes
1 answer

Slow initial show performance of QComboBox with large item count

It looks like calling show on a widget/window that contains a QComboBox with large item count is very slow. Take the following snippet that compares the performance of using QComboBox vs QTreeWidget from PyQt5.QtWidgets import * from PyQt5.QtCore…
danielhrisca
  • 665
  • 1
  • 5
  • 11
2
votes
1 answer

QCombobox with additional data for items next to the string

I'm having a database with two types of one thing. Let's say I have animals and then the two types are birds and fish. I want one combobox in which the two are combined. So basically you can chose any animal either some bird or some fish. In the…
C. Binair
  • 419
  • 4
  • 14
2
votes
1 answer

combo box connect signal should not be triggered when the combo box is empty

I have connected a combo box to a slot on currentIndexChanged value. The issue i am facing is that when i clear all the items from the combo box than also the event gets triggered. Whenever i clear all the items from the combo box i do not want the…
user11498510
2
votes
1 answer

QComboBox add bold parent items

I would like to add some kind of parent items to a pyqt5 combobox which allow grouping of the items below. the parents should be not selectable and bold if possible, the children a little bit indented. What I have got so far: I got them bold but I…
2
votes
1 answer

Get QComboBox item text triggered by event in separate class method/function

I'm having trouble getting any information from a QComboBox other than the index in a function. Most similar examples provides the function in the same class as the triggered event. I'm trying to get this from an external class (and file). Folder…
Cobse
  • 73
  • 11
2
votes
1 answer

ComboBox function currentIndexChanged not working correctly

I have taken two comboBoxes i.e., comboBox1 and comboBox_2 and two functions test and test1 and calling them using currentIndexChanged (self.comboBOx1.currentIndexChanged and self.comboBOx_2.currentIndexChanged). When a value is selected from…
Aamna D
  • 45
  • 1
  • 1
  • 7