Hello friends,
when I create a tabwidget say like this :
for (int i = 0; i < m_DetailInfos.size(); ++i)
{
qlbl_Nr->setObjectName("qlbl_Nr_"+m_DetailInfos.at(i).value(0).toString());
qle_Nr->setObjectName("qle_Nr_"+m_DetailInfos.at(i).value(0).toString());
qle_Nr->setText(m_DetailInfos.at(i).value(0).toString());
qle_Nr->setEnabled(false);
myLayout->addWidget(qlbl_Nr,0,0,1,1,Qt::AlignLeft);
myLayout->addWidget(qle_Nr,0,1,1,1,Qt::AlignLeft);
customWidget1->setLayout(myLayout);
m_qtbw_myTab->addTab(customWidget1,m_DetailInfos.at(i).value(0).toString());
}
m_qtbw_myTab = new QTabWidget(this);
for (int i = 0; i < m_DetailInfos.size(); ++i)
{
QWidget* customWidget1 = new QWidget(m_qtbw_OrderTab) ;
QGridLayout* myLayout = new QGridLayout();
QLabel * qlbl_Nr = new QLabel(tr("Auftrag"),customWidget1);
qlbl_Nr->setObjectName("qlbl_Nr_"+m_DetailInfos.at(i).value(0).toString());
QLineEdit * qle_Nr = new QLineEdit(customWidget1);
qle_Nr->setObjectName("qle_Nr_"+m_DetailInfos.at(i).value(0).toString());
qle_Nr->setText(m_DetailInfos.at(i).value(0).toString());
qle_Nr->setEnabled(false);
myLayout->addWidget(qlbl_Nr,0,0,1,1,Qt::AlignLeft);
myLayout->addWidget(qle_Nr,0,1,1,1,Qt::AlignLeft);
customWidget1->setLayout(myLayout);
m_qtbw_myTab->addTab(customWidget1,m_DetailInfos.at(i).value(0).toString());
}
To copy to clipboard, switch view to plain text mode
And I want access the widget in a special tab I do that with:
QWidget * myWidget
= qobject_cast<QWidget
*>
(m_qtbw_myTab
->widget
(0));
QWidget * myWidget = qobject_cast<QWidget *>(m_qtbw_myTab->widget(0));
To copy to clipboard, switch view to plain text mode
But what about accessing the Lineedit in a Widget??
I see the children during debugging and try this:
QLineEdit * myedit
= qobject_cast<QLineEdit
*>
(myWidget
->childAt
(1,
0));
//lineedit
QLineEdit * myedit = qobject_cast<QLineEdit *>(myWidget->childAt(1,0));//lineedit
To copy to clipboard, switch view to plain text mode
but I get a crash.
Can I access the components on the widget without subclassing the Widget??
Thanx in advance.
Bookmarks