qcombobox

PyQt - QComboBox connection confirmed but function is not being called

梦想的初衷 提交于 2019-11-30 19:32:40
问题 I am having a bit of trouble with the signal/slot issues using PyQt. My code is below, but it probably deserves a bit of explanation. The first two QObject.connect() return True, so I know the connection is established. However, when changing the selection in the comboBox, the function getParameters is not called as expected. The 5 connects below that were for debugging and testing the other signals associated with ComboBox. Those do not print the the log as expected either. From what I've

QComboBox AbstractItemView::item

喜欢而已 提交于 2019-11-30 19:24:30
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 ? Your style sheet seemed correct, so I tried it. It seems the problem is similar to this one on Qt centre : QCompleter sets a custom QAbstractItemDelegate on it's model and unfortunately this custom item delegate does not

Qt Using Custom QItemDelegate for QTableView

我怕爱的太早我们不能终老 提交于 2019-11-29 21:57:34
I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate . It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know when my QItemDelegate is going to be utilized. when itemModel->setData() is used or when itemModel->setItem() . I would suspect setItem() because I reimplemented a QItemDelegate (emphasis on the "Item") but the tutorial uses setData() and it works fine. I know that if the specified QItemDelegate does not work it uses the default one but how do I now

How can I get the selected VALUE out of a QCombobox?

南楼画角 提交于 2019-11-29 21:16:31
In Qt, I can get the selected text of a QComboBox by using the combobox->currentText() method. How can I get the selected value ? I searched for help but I couldn't find a method currentData() which I expected to find. I could only find combobox->currentIndex() Is there a smarter way to do it other than combobox->itemData(combobox->currentIndex()) ? Update: This is no longer necessary as of Qt 5. A currentData() method has been added http://doc.qt.io/qt-5/qcombobox.html#currentData-prop It seems you need to do combobox->itemData(combobox->currentIndex()) if you want to get the current data of

QComboBox with checkboxes

与世无争的帅哥 提交于 2019-11-29 11:14:13
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... 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 view to prevent its closing when you click on it: bool SomeObject::eventFilter(QObject *obj, QEvent *event) {

QStandardItem + QComboBox

回眸只為那壹抹淺笑 提交于 2019-11-29 09:44:59
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? Kip Streithorst 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(new QStandardItem("A")); pModel->appendRow(new QStandardItem("D")); What we created above is a

Checkboxes in a Combobox using PyQt

狂风中的少年 提交于 2019-11-29 07:23:24
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. 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 to a button. Then connect either the menu or the actions to a slot. The code in Qt(haven't use PyQt yet,

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

女生的网名这么多〃 提交于 2019-11-28 20:55:09
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? armonge Try this code, is something i used in a project of mine import sys from PyQt4.QtGui import QComboBox, QApplication, QCompleter, QSortFilterProxyModel, QStandardItemModel, QStandardItem from PyQt4.QtCore import Qt class ExtendedCombo( QComboBox ): def __init__( self, parent =

Qt Using Custom QItemDelegate for QTableView

痴心易碎 提交于 2019-11-28 17:17:43
问题 I followed the Spin Box Delegate tutorial, which Qt provides, to try to implement my own QItemDelegate . It would be used to specify a QComboBox to represent data in a QTableView cell but it is not working. My biggest problem is that I don't know when my QItemDelegate is going to be utilized. when itemModel->setData() is used or when itemModel->setItem() . I would suspect setItem() because I reimplemented a QItemDelegate (emphasis on the "Item") but the tutorial uses setData() and it works

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

戏子无情 提交于 2019-11-28 10:40:20
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 ? Jérôme 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 theme engine. To make sure your background color will be correct, I would suggest to use the Qt