for(int i=0;i<9;i++){
label->setText("first line\nsecond line");
label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
label->setGeometry(10*i,80,120,50);
}
for(int i=0;i<9;i++){
QLabel *label = new QLabel(&fenster);
label->setFrameStyle(QFrame::Panel | QFrame::Sunken);
label->setText("first line\nsecond line");
label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
label->setGeometry(10*i,80,120,50);
}
To copy to clipboard, switch view to plain text mode
This will more or less work, but two more potential errors are here:
QLabel *label = new QLabel(&fenster);
To copy to clipboard, switch view to plain text mode
By that code I guess "fenster" is a stack allocated object which can go out of scope. It should be allocated on heap (just like I corrected the labels here)
label->setGeometry(10*i,80,120,50);
label->setGeometry(10*i,80,120,50);
To copy to clipboard, switch view to plain text mode
Based on this I guess you are not using layouts, while you probably should.
Bookmarks