qcombobox

Show item in a QComboBox but not in its popup list

爷,独闯天下 提交于 2019-12-10 21:15:29
问题 I have some code to use a combobox to show a list of products. I would like to show "Select product" in the combobox: products = ["Select product", "223", "51443" , "7335"] but I do not want the user to be able to select the "Select product" item. I just want the user to know what this combobox is used for selecting the product, and I do not wish to use QLabel to identify it. page.comboBox.addItems(products) page.comboBox.setPlaceHolderText("Please select") page.comboBox.setGeometry(150, 30,

Style QComboBox popup menu margin Qt 4

孤街浪徒 提交于 2019-12-10 18:53:15
问题 After countless hours trying to style a QComboBox, I'm stuck with the top and bottom margin where the items are inserted. I would like to either remove or apply a background-color to the popup menu top and bottom white spaces. QComboBox screen http://img576.imageshack.us/img576/3402/screenshot20120130at144.png I added a min-height to the QListView not to show top and bottom arrows. I also looked at the QComboBoxPrivate class in Qt sources but it seems that the top and bottom margins are

Qt - Set display text of non-editable QComboBox

穿精又带淫゛_ 提交于 2019-12-10 18:34:53
问题 I would like to set the text of a QComboBox to some custom text (that is not in the QComboBox's list), without adding this text as an item of the QComboBox. This behaviour is achievable on an editable QComboBox with QComboBox::setEditText(const QString & text) . On a non-editable QComboBox, however, this function does nothing. Is it possible to programmatically set the display/edit text of a non-editable QComboBox to something that is not in its list? Or do I have to find another way (e.g.

Pyqt prevent combobox change value

拥有回忆 提交于 2019-12-10 18:19:04
问题 I have four combo-box boxes that in PyQT4 . If user change the value in first combo-box the values from second are altered and similarly if the value in second combo-box change, that results in the change of thirds combo-box and the same case for the fourth combo-box. What i want is when i change the value i first combo-box it should result in change of only second combo-box while does not effect the changes in third and fourth combo-box. How can i do this in PyQt ? I have changedIndex event

Problem in restoring floating toolbar for QMainWindow

不羁的心 提交于 2019-12-10 13:32:34
问题 I am seeing a problem while restoring QMainWindow state having QCombobox in floating toolbar. After restoring floating toolbar, my QCombobox is not able to get focus until i click on toolbar handle and move it. Following is gif showing problem, Using QT 5.13. File floating_toolbar.pro QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = floating_toolbar TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs

How to Drag and Drop from ListWidget onto ComboBox

随声附和 提交于 2019-12-10 10:48:50
问题 The goal is to be able to drag-and-drop ListWidget items onto the comboBox. The dropped items should be added to the combobox. Ideally we want to avoid any tricks with reading listWidget's .currentItem() or .selectedItems() and etc... Ideas? from PyQt4 import QtGui, QtCore import sys, os class MyClass(object): def __init__(self): super(MyClass, self).__init__() self.name=None def setName(self, arg): self.name=arg def getName(self): return self.name class DropableComboBox(QtGui.QComboBox): def

Key/Value pyqt QComboBox

拈花ヽ惹草 提交于 2019-12-10 04:36:53
问题 I want to use a QComboBox with the "keys" and "values" from a tuple similar to the ones used in a django models. For example I have the following structure for a person's sex. SEX_CHOICES = (('M', 'Male'), ('F', 'Female')) The first item of the tuple contains the code of the sex that is stored in the database, and the second one the text that I want to display in the QComboBox as an item. Is there a way in wich I could set the QComboBox value as M and it displays Male. An also when the user

How can I add item data to QComboBox from Qt Designer/.ui file

女生的网名这么多〃 提交于 2019-12-08 19:12:04
问题 I'm using Qt Designer (well, Qt Creator actually, but specifically the part derived from Qt Designer), and I've added a few QComboBox items to a dialog with a constant list of items. I need to map the items in the combo box to strings (which are distinct from the displayed strings). The best idea I've come up for it is to use the QComboBox::itemData function to get the needed string from the selected item, but I'm having trouble adding the associated strings to the items. I've looked all over

Error in model view implemention of GUI in pyqt

余生长醉 提交于 2019-12-07 23:12:26
问题 the following sample code is crashing with this error when I close the application: QBasicTimer::start: QBasicTimer can only be used with threads started with QThread here is my code : import sys from PyQt4 import QtGui ,QtCore app = QtGui.QApplication(sys.argv) data=[] data.append("one") model=QtGui.QStringListModel(data) combobox=QtGui.QComboBox() combobox.show() combobox.setModel(model) sys.exit(app.exec_()) I found out that's about using model but I don't know how to fix it. edited: os :

Qt - How to use rich text in a QComboBox?

孤街醉人 提交于 2019-12-07 07:46:01
问题 I am trying to use rich text in a QComboBox but it does not support it. Perhaps I should write a subclass? But I am unsure on what I would need to override as I have never done anything like this before. Please help. Thanks! 回答1: I think custom delegate class is the answer. The solution is to simply replace standard drawing routine with your own (using i.e. QLabel). There was a similar question here: QListView/QListWidget with custom items and custom item widgets 来源: https://stackoverflow.com