It very well may be that I didn't understand your post.
But one way to do it is by creating a simple custom widget something like
{
Q_OBJECT
public:
InfoWidget(const group &grp); //in the implementations you set the member widgets in the layout as you did in createCellWidget()
~InfoWidget ();
public slots:
void go_clicked();
protected:
}
class InfoWidget : public QWidget
{
Q_OBJECT
public:
InfoWidget(const group &grp); //in the implementations you set the member widgets in the layout as you did in createCellWidget()
~InfoWidget ();
public slots:
void go_clicked();
protected:
QComboBox m_comBox;
QLabel m_label;
QToolBox m_toolBox;
QPushButton m_button;
}
To copy to clipboard, switch view to plain text mode
InfoWidget::InfoWidget(const group &grp)
{
foreach (place p, grp.building)
m_comBox.addItem(p.placename);
m_comBox->setMaximumWidth(200);
m_button.setText("Go");
m_button.setMaximumWidth(50);
m_label.setText(grp.grpname);
layout->addWidget(&m_label, 0, 0);
layout->addWidget(&m_combo, 1, 0);
layout->addWidget(&m_button,1,1);
setLayout(layout);
connect(&m_button, SIGNAL(clicked()), this, SLOT(go_clicked()));
}
InfoWidget::InfoWidget(const group &grp)
{
foreach (place p, grp.building)
m_comBox.addItem(p.placename);
m_comBox->setMaximumWidth(200);
m_button.setText("Go");
m_button.setMaximumWidth(50);
m_label.setText(grp.grpname);
QGridLayout *layout = new QGridLayout();
layout->addWidget(&m_label, 0, 0);
layout->addWidget(&m_combo, 1, 0);
layout->addWidget(&m_button,1,1);
setLayout(layout);
connect(&m_button, SIGNAL(clicked()), this, SLOT(go_clicked()));
}
To copy to clipboard, switch view to plain text mode
now you can access all the elements in the slot:
InfoWidget::go_clicked()
{
//m_button, m_comBox, m_label are all members and can be accessed.
}
InfoWidget::go_clicked()
{
//m_button, m_comBox, m_label are all members and can be accessed.
}
To copy to clipboard, switch view to plain text mode
and then you can do something like:
QWidget *disp
::createCellWidget(group grp
) {
// QVector<InfoWidget*> m_infoWidgets; in the header
InfoWidget *pInfoWidget = new InfoWidget(group);
m_infoWidgets.push_back(pInfoWidget);
return infoWidget;
}
QWidget *disp::createCellWidget(group grp)
{
// QVector<InfoWidget*> m_infoWidgets; in the header
InfoWidget *pInfoWidget = new InfoWidget(group);
m_infoWidgets.push_back(pInfoWidget);
return infoWidget;
}
To copy to clipboard, switch view to plain text mode
Please note that this is more like pseudo code, I did not test for compilation, it more to illustrate the idea I am suggesting.
Bookmarks