...
private slots:
void go_clicked();
private:
void createPlace();
QWidget *createCellWidget
(group grp
);
mapinfo map; <-- struct
...
private slots:
void go_clicked();
private:
void createPlace();
QWidget *createCellWidget(group grp);
mapinfo map; <-- struct
QToolBox *toolbox;
QLabel *grp;
QComboBox *combo
To copy to clipboard, switch view to plain text mode
...
void disp::createPlace()
{
int i = 0;
foreach (group grp, map.grp) {
layout->addWidget(createCellWidget(grp), i, 0);
i++;
}
layout->setRowStretch(i, 10);
itemWidget->setLayout(layout);
toolbox->setMinimumWidth(itemWidget->sizeHint().width());
toolbox->addItem(itemWidget,"Select Place");
}
QWidget *disp
::createCellWidget(group grp
) {
foreach (place p, grp.building)
combo->addItem(p.placename);
combo->setMaximumWidth(200);
btn->setText("Go");
btn->setMaximumWidth(50);
grpname->setText(grp.grpname);
layout->addWidget(grpname, 0, 0);
layout->addWidget(combo, 1, 0);
layout->addWidget(btn,1,1);
widget->setLayout(layout);
connect(btn, SIGNAL(clicked()), this, SLOT(go_clicked()));
return widget;
}
void disp::go_clicked()
{
//something with own group's combo text and label text
qDebug() << grpname->text() << " ----- " << combo->currentText(); //testing
}
...
void disp::createPlace()
{
int i = 0;
QGridLayout *layout = new QGridLayout;
foreach (group grp, map.grp) {
layout->addWidget(createCellWidget(grp), i, 0);
i++;
}
layout->setRowStretch(i, 10);
QWidget *itemWidget = new QWidget;
itemWidget->setLayout(layout);
toolbox = new QToolBox;
toolbox->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Ignored);
toolbox->setMinimumWidth(itemWidget->sizeHint().width());
toolbox->addItem(itemWidget,"Select Place");
}
QWidget *disp::createCellWidget(group grp)
{
combo = new QComboBox;
foreach (place p, grp.building)
combo->addItem(p.placename);
combo->setMaximumWidth(200);
QPushButton *btn = new QPushButton;
btn->setText("Go");
btn->setMaximumWidth(50);
grp = new QLabel;
grpname->setText(grp.grpname);
QGridLayout *layout = new QGridLayout;
layout->addWidget(grpname, 0, 0);
layout->addWidget(combo, 1, 0);
layout->addWidget(btn,1,1);
QWidget *widget = new QWidget;
widget->setLayout(layout);
connect(btn, SIGNAL(clicked()), this, SLOT(go_clicked()));
return widget;
}
void disp::go_clicked()
{
//something with own group's combo text and label text
qDebug() << grpname->text() << " ----- " << combo->currentText(); //testing
}
To copy to clipboard, switch view to plain text mode
Bookmarks