qcombobox

PyQt Different colors in a single row in a combobox

和自甴很熟 提交于 2020-01-11 06:30:09
问题 I'm developing a UI using PyQt where a single item in my Qcombobox can have two or three words separated by commas. So for eg item 1 can be ' Text1, Text2, Text3 ' and item 2 will be ' Text4, Text5 '. What I want to do is give multiple background colors to the items separated by the ',' in the itemText. So, in case of item 1 (' Text1, Text2, Text3 ') I would need a color behind Text1 , a different one behind Text2 and a third one behind Text3 . Similarly, item 2 would have 2 background colors

QComboBox AbstractItemView::item

喜你入骨 提交于 2020-01-11 01:36:12
问题 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 with no result. QComboBox QAbstractItemView::item {min-height: 20px;} Is it possible to achieve this at style-sheet level at all ? 回答1: Your style sheet seemed correct, so I tried it. It seems the problem is similar to this one on Qt centre:

Qt QComboBox popup position

有些话、适合烂在心里 提交于 2020-01-06 03:15:06
问题 I'm working on an application which contains an editable QComboBox. I observe the following behavior when I enter some text in the edit field and press the dropdown arrow in the combobox: My edit line ends up hidden behind the item "e@abc.com". I would like to have the combobox list popup below the edit field, like in the below screen: The first screen above is taken on Ubuntu with Qt4.5 while the second screen is from Suse 11 with Qt 4.4. I'm not aware of any differences regarding change of

How can I change the contents of one QComboBox depending on another QComboBox in PyQt5?

喜欢而已 提交于 2020-01-01 20:10:13
问题 I write program on python3 that will calculate thermodynamic properties. This is piece of GUI "Выбранное вещество" is a selected substance like 1-Butene, water, ammonia and etc. "Первый параметр" is a first parameter. User will choose parameters like pressure, temperature, density and etc, and unit of measurement like Pa, MPa, bar (if it's pressure) and etc. So I don't know one thing: i want that if user chose pressure('Давление (P)') in top combobox, depending on this, suitable units of

QCombobox works very slow with QSqlQueryModel with large model

随声附和 提交于 2019-12-30 11:27:49
问题 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 QSqlQueryModel without threading to improve performance but experienced it works much slower than QStandardItemModel (in our project QSqlQueryModel works very fast with such amount of data with QTreeView for example). What could be the problem here? Is

Qt how to change the highlight color of a specific QComboBox item

穿精又带淫゛_ 提交于 2019-12-30 09:56:31
问题 I'm trying to make the highlight transparent for a QComboBox. The color of this QComboBox also changes based on the selected index. Here is my best solution so far: switch(comboBox->currentIndex()) { case 0: comboBox->setStyleSheet("QWidget {color:black}"); break; case 1: comboBox->setStyleSheet("QWidget {background-color:red; color:white;}"); break; case 2: comboBox->setStyleSheet("QWidget {background-color:green; color:white;}"); break; } comboBox->setItemData(0, QColor(Qt::white), Qt:

QComboBox with checkboxes

给你一囗甜甜゛ 提交于 2019-12-29 07:52:07
问题 I'm creating QComboBox with checkboxes. How I can prevent collapsing of view on mouse clicking? I want to be able to set up checkboxes, but each time I click on item - drop-down of QComboBox is collapsed. Note: currently I'm debugging Qt sources and looking for workaround... 回答1: First of all you need to install an event filter to the combo box view, i.e.: combobox->view()->viewport()->installEventFilter(someobj); than you need to filter all mouse release events that happen on the combo box

QCombo box to set layer (for Python QGIS plugin)

天涯浪子 提交于 2019-12-25 06:37:52
问题 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 combobox.currentIndex() isn't giving me what I think it is. If this is the case, I wonder if I should find a way set the combo box's index to something by default before the program runs. #connecting the combo boxes to function def initGui(self): QObject.connect(self

How to subscript string in QComboBox's addItem

人走茶凉 提交于 2019-12-24 14:06:02
问题 I am trying to enter a chemical formula using addItem to a QComboBox, but I do not know how to subscript the numbers. I would really appreciate any help I can receive. I have tried: 1. Using dollar signs ($) before and after the number "$\3$" 2. Using curly brackets and dollar signs "$_{3}$" 3. Using Unicode formatting "\u2083". This one works but it only shows the sub scripted number when you see the options of the drop down menu. After you select the option, it'll display a vertical bar in

Disabling QComboBox in pyqt

偶尔善良 提交于 2019-12-23 10:54:18
问题 Is it possible to disable QComboBox in pyqt like we can do it in Win Forms(C#) since I could not find any option in the QComboBox manual. I want to enable QcomboBox only when admin logins. 回答1: I found the answer to my question, QComboBox.setEnabled(False) # disable comboBox and QComboBox.setEnabled(True) # enable comboBox 回答2: You can also do : QComboBox.setDisabled(True) QComboBox.setDisabled(False) 来源: https://stackoverflow.com/questions/20468602/disabling-qcombobox-in-pyqt