qcombobox

QComboBox: Only show the icons when expanded

ぐ巨炮叔叔 提交于 2021-02-19 03:09:23
问题 Starting from a "normal" QCombobox I'd like to get a QCombobox that only shows the icon when it's expanded, but not when it's collapsed. I've found several answers to similar questions, but all of them show code for much more complex situations and I have not managed to distill the core of it. There are two approaches I've seen: attaching a QListView or using a QItemDelegate (or both). But I could not find any sample code that is straight to the point. This is my starting point: MainWindow:

QComboBox: Only show the icons when expanded

試著忘記壹切 提交于 2021-02-19 03:08:06
问题 Starting from a "normal" QCombobox I'd like to get a QCombobox that only shows the icon when it's expanded, but not when it's collapsed. I've found several answers to similar questions, but all of them show code for much more complex situations and I have not managed to distill the core of it. There are two approaches I've seen: attaching a QListView or using a QItemDelegate (or both). But I could not find any sample code that is straight to the point. This is my starting point: MainWindow:

QComboBox: Only show the icons when expanded

二次信任 提交于 2021-02-19 03:07:49
问题 Starting from a "normal" QCombobox I'd like to get a QCombobox that only shows the icon when it's expanded, but not when it's collapsed. I've found several answers to similar questions, but all of them show code for much more complex situations and I have not managed to distill the core of it. There are two approaches I've seen: attaching a QListView or using a QItemDelegate (or both). But I could not find any sample code that is straight to the point. This is my starting point: MainWindow:

How do i use QComboBox.setPlaceholderText?

左心房为你撑大大i 提交于 2021-02-16 17:59:28
问题 In Qt 5.15 the placeholderText property was introduced - link to documentation However using setPlaceholderText doesn't do anything for me . When running the code below i don't get any text in the QComboBox (unless of course i select one of the three items) Is this a bug or am i missing something? How can i make this work? import sys from PyQt5 import QtWidgets from PyQt5 import QtCore class MainWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() central_w = QtWidgets

How to open a dialog after QComboBox choice

让人想犯罪 __ 提交于 2021-02-11 14:50:40
问题 I have a QComboBox with several choices on a QToolBar . Every choice of the QComboBox will open a specific dialog window. The problem I have is that after I choose the preferred index on the combobox no dialogs opens up. For simplicity of the example I am linking the same dialog to all choices: dredgewindow.h This is the header file namespace Ui { class DredgeWindow; } class DredgeWindow : public QMainWindow { Q_OBJECT public: explicit DredgeWindow(QWidget *parent = nullptr); ~DredgeWindow();

How to update a QTableView cell with a QCombobox selection?

不羁的心 提交于 2021-02-08 04:36:39
问题 I want to add a delegate QComboBox delegate to specific cells in some of the QTableView rows. I've found several posts on how to add the delegate, but none with examples for updating a cell with the QComboBox selection. This is what I have so far: main.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Dialog</class> <widget class="QDialog" name="Dialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>350</width> <height>239</height> </rect> </property> <property

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

家住魔仙堡 提交于 2021-02-05 07:39:57
问题 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 to use a QComboBox. I've got everything pretty much working, except that when I select the item from the QComboBox in any of the cells in column 3, it doesn't populate. Does it have something to do with my setModelData() method? I also have a clear

How to change just one item of QCombobox to editable by user

半腔热情 提交于 2021-01-29 12:23:01
问题 I have 4 items in my QCombobox , 'Bryce king' 'James White' 'Russo W' 'Custom Manager' So, when I click on "Custom Manager" , it should change to editable and I must be able to enter my own desired name. I have tried to achieve this behavior using QtCreator, and in the properties, I can set it to editable but that would make all items editable instead of just one. 回答1: First make sure your combobox's editable property is set to false. Then you can use the QComboBox::currentIndexChanged signal