qmenu

One QAction checkable at time in QMenu

两盒软妹~` 提交于 2019-12-02 14:05:00
问题 I am trying to make my choices from QMenu to be checkable in a way that only one might be selected at time and first item is set checked by default (this works actually). Here is a snippet of my code: paymentType = QMenu('Payment Type', self) paymentType.addAction(QAction('Cash', paymentType, checkable=True, checked = True)) paymentType.addAction(QAction('Noncash Payment', paymentType, checkable=True)) paymentType.addAction(QAction('Cash on Delivery', paymentType, checkable=True)) paymentType

How to pass a QString to a Qt slot from a QMenu via QSignalMapper or otherwise

自古美人都是妖i 提交于 2019-12-01 17:07:46
I have a QMenu with many submenus. These are dynamically created i.e. the names menus come from a db and created in a loop. Now i wanted to fire the same slot triggered() or similar when a menu is clicked, but i needed the QString menu name to be passed to slot so i could perform menu specific actions. I have tried this i.e. passing a QAction * to the triggered event and used setData but i am getting the run time error. object::connect: No such signal QAction::triggered(QAction *) for(int j=0; j<channelTypes[i].getNumChannels() ; j++){ QAction *subMenuAct = subMenu->addAction(tr(c_name)); // c

QMenu: How to customize the menu items of QMenu

假装没事ソ 提交于 2019-11-30 09:29:14
问题 I want to build a dropdown list control with QPushButton and QMenu like below: QPushButton* menuBt = new QPushButton("Please select"); menuBt->setFlat(true); QMenu* menu = new QMenu(); menuBt->setMenu(menu); QWidgetAction* wa1 = new QWidgetAction(menu); QLabel* l1 = new QLabel("Option1"); wa1->setDefaultWidget(l1); menu->addAction(wa1); QWidgetAction* wa2 = new QWidgetAction(menu); QLabel* l2 = new QLabel("Option2"); wa2->setDefaultWidget(l2); menu->addAction(wa2); menu->setStyleSheet("QMenu:

QMenu: How to customize the menu items of QMenu

拟墨画扇 提交于 2019-11-29 15:38:19
I want to build a dropdown list control with QPushButton and QMenu like below: QPushButton* menuBt = new QPushButton("Please select"); menuBt->setFlat(true); QMenu* menu = new QMenu(); menuBt->setMenu(menu); QWidgetAction* wa1 = new QWidgetAction(menu); QLabel* l1 = new QLabel("Option1"); wa1->setDefaultWidget(l1); menu->addAction(wa1); QWidgetAction* wa2 = new QWidgetAction(menu); QLabel* l2 = new QLabel("Option2"); wa2->setDefaultWidget(l2); menu->addAction(wa2); menu->setStyleSheet("QMenu::item {font-family: \"Arial\"; font-size: 13pt; color: #808080; border: 1px solid gray; background

How to add a list of QActions to a QMenu and handle them with a single slot?

大城市里の小女人 提交于 2019-11-29 06:10:25
First, I have a list of QWidget s that I won't know the length of until runtime. I then create a QListWidget where I show them and when someone clicks them I use the signal currentItemChanged(QListWidgetItem*, QListWidgetItem*) to catch it and get the clicked item's index. Now I want to do a similar thing in the QMenu . I will know the list when the QMenu and its actions get built, but I won't be able to hard code this. How can I create actions, catch their signals and connect them to the same slot which does different things depending on the action's position (index) in the menu list? There