qcombobox

QStandardItem + QComboBox

喜你入骨 提交于 2019-11-28 03:05:55
问题 I am trying to put a QComboBox into a QStandardItem to be used in a QStandardItemModel . I have been looking around and I cannot find an answer, any ideas? 回答1: You don't store a QComboBox in a QStandardItemModel . Let's say you have the following choices: A B C D and you have a list with two items in a QListView , the first value being A the second being D: QListView* pView = new QListView(); QStandardItemModel* pModel = new QStandardItemModel(); pView->setModel(pModel); pModel->appendRow

Checkboxes in a Combobox using PyQt

纵然是瞬间 提交于 2019-11-28 01:02:29
问题 I need to implement a drop down list that contains CheckBoxes, much like having the entries in a ComboBox being CheckBoxes. But QComboBox doesn't accept QCheckBox as its member and I couldn't find any alternate solution. I found an implementation in C++ on the Qt Wiki, but don't know how to port it to python. 回答1: When i needed this, I come up with an easier solution (at least it is not necessary to subclass QCombobox). It worked for me. That is create a menu with checkable actions and set it

PyQt: How to set Combobox Items be Checkable?

泪湿孤枕 提交于 2019-11-27 14:52:41
To keep the GUI widgets number to minimum I need to find a way to give to user a choice of pull-down menu items that could be used to filter out the displayed in a listWidget items. Let's say the listWidget lists 5 different categories of Items: "Cat A", "Cat B","Cat C","Cat D","Cat E". I could implement the radio or checkboxes for each item category. But then 5 radio buttons or checkboxes would take a lot of GUI space. A combobox with the checkable items seems to be a right choice. Any ideas? from PyQt4 import QtGui, QtCore import sys, os class CheckableComboBox(QtGui.QComboBox): def __init__

How do you get the current text contents of a QComboBox?

别来无恙 提交于 2019-11-27 13:55:41
Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the option is selected, but the problem is that when the user clicks run, the contents of several of these comboboxes need to be taken into account. So basically I need to get the selected contents of a combobox as a string. Thus far I have only been able use this: print combobox1.currentText() to get this: PyQt4.QtCore.QString(u'Test Selection2') when all I really want is the 'Test Selection' bit, any

ComboBox function currentIndexChanged not working correctly

江枫思渺然 提交于 2019-11-27 08:19:40
问题 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 comboBox1 its corresponding function(self.comboBOx1.currentIndexChanged) is called and same for comboBox_2. On selection of value from comboBox1 changes the values in comboBox_2 and its working fine. But the problem I have got here is that at first when

How do I Filter the PyQt QCombobox Items based on the text input?

好久不见. 提交于 2019-11-27 05:44:44
问题 I need a QCombox which Items are filtered based on the text input. If I set the QCombobox editable, the user can insert text and the QCompleter is automatically created. But the items are not filtered and I don’t want the user to add new Items. Is there any possibility to add this functionality to the QCombobox? 回答1: Try this code, is something i used in a project of mine import sys from PyQt4.QtGui import QComboBox, QApplication, QCompleter, QSortFilterProxyModel, QStandardItemModel,

How do I set the background color of a widget like combobox or double spin box?

瘦欲@ 提交于 2019-11-27 03:43:52
问题 I am trying to set the background color for a double spin box, and I am not sure what function I should use. I saw some function called SetBackgroundRole which accepts a Qt::ColorRole , but I am not sure how to use this one as well. Kindly let me know, what's the simple way to change the background color of a QComboBox or QDoubleSpinBox ? 回答1: Using a QPalette isn't guaranteed to work for all styles, because style authors are restricted by the different platforms' guidelines and by the native

How to add items to a combobox in PyQt

若如初见. 提交于 2019-11-27 01:48:57
问题 I need some help adding some items to a QComboBox . So I have two comboboxes, and one populates the other depending on the item selected. My question is that, using additem for new items, it works, but if I choose another option for the combobox, it adds the new items, but the previous items are gone - and there are blank items below the new ones. I thought that each time I chose a new option from the first combobox to clear the contents of the second combobox. So I used the clear() on the

How do you get the current text contents of a QComboBox?

放肆的年华 提交于 2019-11-26 20:35:53
问题 Using pyqt4 and python 2.6, I am using a qcombobox to provide a list of options. I am having problems with using the selected option. I have been able to use a signal to trigger a method when the option is selected, but the problem is that when the user clicks run, the contents of several of these comboboxes need to be taken into account. So basically I need to get the selected contents of a combobox as a string. Thus far I have only been able use this: print combobox1.currentText() to get

QCompleter Custom Completion Rules

假如想象 提交于 2019-11-26 18:49:47
I'm using Qt4.6 and I have a QComboBox with a QCompleter in it. The usual functionality is to provide completion hints (these can be in a dropdown rather than inline - which is my usage) based on a prefix. For example, given chicken soup chilli peppers grilled chicken entering ch would match chicken soup and chilli peppers but not grilled chicken . What I want is to be able to enter ch and match all of them or, more specifically, chicken and match chicken soup and grilled chicken . I also want to be able to assign a tag like chs to chicken soup to produce another match which is not just on the