Hi,
I am trying to put some buttons dynamically into a QGridLayout, that is in a QTabView. Therefore I put that QGridLayout into a tab and fill it with the buttons.
The problem is, that when I add more than 4 Buttons to that layout it changes its parent somwhow and I get an error. The error occurs, when the button shall be added to the layout.
Error:
parent
: QWidget(0x289be8, name
= "tabUserSpecificMethods") parent
: QWidget(0x289be8, name
= "tabUserSpecificMethods") parent
: QWidget(0x289be8, name
= "tabUserSpecificMethods") parent
: QWidget(0x289be8, name
= "tabUserSpecificMethods") parent
: QWidget(0x289be8, name
= "tabUserSpecificMethods") parent: screenMeasMeth(0x260830, name = "screenMeasMeth")
QLayout::parentWidget: A layout can only have another layout as a parent.
Segmentation fault
Error:
parent: QWidget(0x289be8, name = "tabUserSpecificMethods")
parent: QWidget(0x289be8, name = "tabUserSpecificMethods")
parent: QWidget(0x289be8, name = "tabUserSpecificMethods")
parent: QWidget(0x289be8, name = "tabUserSpecificMethods")
parent: QWidget(0x289be8, name = "tabUserSpecificMethods")
parent: screenMeasMeth(0x260830, name = "screenMeasMeth")
QLayout::parentWidget: A layout can only have another layout as a parent.
Segmentation fault
To copy to clipboard, switch view to plain text mode
my Code looks like that:
VLaytUserSpecificMethods
= new QGridLayout(ui
->tabUserSpecificMethods
);
VLaytUserSpecificMethods->setHorizontalSpacing(6);
VLaytUserSpecificMethods->setVerticalSpacing(6);
VLaytUserSpecificMethods
->setObjectName
(QString::fromUtf8("VLaytUserSpecificMethods"));
VLaytUserSpecificMethods->setContentsMargins(10, 15, 0, 0);
VLaytUserSpecificMethods
->setGeometry
(QRect(0,
0,
431,
490));
for(int i = 0; i <= tmpMethodNames.size()-1; i++){
listBtnUserMeasMeth[i]->setVisible(true);
listBtnUserMeasMeth[i]->setText(tmpMethodNames.at(i));
listBtnUserMeasMeth
[i
]->setMaximumSize
(QSize(200,
55));
listBtnUserMeasMeth
[i
]->setMinimumSize
(QSize(200,
55));
listBtnUserMeasMeth[i]->setStyleSheet(globalStyleSheet::btnEnabled);
listBtnUserMeasMeth[i]->setFont(dynamicBtnFont);
listBtnUserMeasMeth[i]->setFocusPolicy(Qt::NoFocus);
qDebug() << "parent: " << VLaytUserSpecificMethods->parent();
if(i % 2 == 0){
VLaytUserSpecificMethods->addWidget(listBtnUserMeasMeth[i],c_GridRowCounter,0);
}
else{
VLaytUserSpecificMethods->addWidget(listBtnUserMeasMeth[i],c_GridRowCounter,1);
c_GridRowCounter++;
}
}
VLaytUserSpecificMethods->addItem(VSpacerBtnList,++c_GridRowCounter,0);
VLaytUserSpecificMethods = new QGridLayout(ui->tabUserSpecificMethods);
VLaytUserSpecificMethods->setHorizontalSpacing(6);
VLaytUserSpecificMethods->setVerticalSpacing(6);
VLaytUserSpecificMethods->setObjectName(QString::fromUtf8("VLaytUserSpecificMethods"));
VLaytUserSpecificMethods->setContentsMargins(10, 15, 0, 0);
VLaytUserSpecificMethods->setGeometry(QRect(0,0,431,490));
for(int i = 0; i <= tmpMethodNames.size()-1; i++){
listBtnUserMeasMeth[i] = new QPushButton(this);
listBtnUserMeasMeth[i]->setVisible(true);
listBtnUserMeasMeth[i]->setText(tmpMethodNames.at(i));
listBtnUserMeasMeth[i]->setMaximumSize(QSize(200,55));
listBtnUserMeasMeth[i]->setMinimumSize(QSize(200,55));
listBtnUserMeasMeth[i]->setStyleSheet(globalStyleSheet::btnEnabled);
listBtnUserMeasMeth[i]->setFont(dynamicBtnFont);
listBtnUserMeasMeth[i]->setFocusPolicy(Qt::NoFocus);
qDebug() << "parent: " << VLaytUserSpecificMethods->parent();
if(i % 2 == 0){
VLaytUserSpecificMethods->addWidget(listBtnUserMeasMeth[i],c_GridRowCounter,0);
}
else{
VLaytUserSpecificMethods->addWidget(listBtnUserMeasMeth[i],c_GridRowCounter,1);
c_GridRowCounter++;
}
}
VLaytUserSpecificMethods->addItem(VSpacerBtnList,++c_GridRowCounter,0);
To copy to clipboard, switch view to plain text mode
Does anybody know the reason, why this happens?
Bookmarks