-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdropdownbutton.cpp
More file actions
45 lines (35 loc) · 856 Bytes
/
Copy pathdropdownbutton.cpp
File metadata and controls
45 lines (35 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "dropdownbutton.h"
#include <qmenu.h>
DropDownButton::DropDownButton(QWidget *parent) : QToolButton(parent)
{}
void DropDownButton::init(Matrice* mat)
{
this->matrice=mat;
QMenu *menu=new QMenu ;
for(auto it : matrice->getListSommet())
{
QString qs;
qs=qs.fromStdString(it.getName());
menu->addAction(qs);
}
setMenu(menu);
}
void DropDownButton::dropdown()
{
QMenu *menu=new QMenu ;
for(auto it : matrice->getListSommet())
{
QString qs;
string text=it.getName();
qs=qs.fromStdString(text);
QAction* qa=new QAction(qs);
qa->setText(qs);
QObject::connect(qa,SIGNAL(triggered()),this,SLOT(setButtonText(qs)));
menu->addAction(qs);
}
setMenu(menu);
}
void DropDownButton::setButtonText(QString s)
{
setText(s);
}