1

I'm trying to create a button with a drop-down list but at the same time, I want the current selected text to be able to activated like a QPushButton. Here are a couple of pics of what I'm looking for, before and after. (Line from MS Paint)

I want to have it so if the user clicks to the left of the line, it will resend the signal of whatever item is shown. If the user clicks the drop-down arrow, that list will show up and from then on will act like a normal Group Box until another Item is selected.

http://imgur.com/a/tFoLv

4

1 に答える 1

2

QToolButtonあなたはそれのためにとを使うことができますQMenu

QToolButton *btn = new QToolButton();
btn->setPopupMode(QToolButton::MenuButtonPopup);

QMenu *btnMenu = new QMenu;
QAction *action1 = btnMenu->addAction("action1");
QAction *action2 = btnMenu->addAction("action2");
btn->setMenu(btnMenu);

connect(btn, SIGNAL(clicked()), this, SLOT(btnSlot()));
connect(action1, SIGNAL(triggered()), this, SLOT(action1Slot()));
connect(action2, SIGNAL(triggered()), this, SLOT(action1Slot()));
于 2013-03-07T09:19:17.100 に答える