Ok let's say you have a program like structured like this:
CObject Objects in the table, like 25
CTable Table for QScrollArea
main where you display QScrollArea
In CTable you do this (assume all objects declared):
iObjects = 25;
setLayout(lay);
for(int i = 0; i < iObjects; i++){
buttons <<
new QPushButtons
(QString("%1").
arg(i
));
}
}
// ASSUME XPOS AND YPOS ARE CORRECTLY DECLARED
for(int i = 0; i < iObjects; i++){
buttons[i]->move(xpos*150+10, ypos*101+10);
}
}
CTable::CTable(QWidget *parent) : QWidget(parent) {
iObjects = 25;
QGridLayout *lay = new QGridLayout;
setLayout(lay);
for(int i = 0; i < iObjects; i++){
buttons << new QPushButtons(QString("%1").arg(i));
}
}
void CTable::resizeEvent(QResizeEvent *evt){
// ASSUME XPOS AND YPOS ARE CORRECTLY DECLARED
for(int i = 0; i < iObjects; i++){
buttons[i]->move(xpos*150+10, ypos*101+10);
}
}
To copy to clipboard, switch view to plain text mode
And in main
qs->setWidget(ctable);
QScrollArea* qs = new QScrollArea;
qs->setWidget(ctable);
To copy to clipboard, switch view to plain text mode
Code has been shortened for clarity!!!
The idea here is, I am building 25 custom widgets (I used buttons here for simplicity, with a QList), and they have to automatically resize and list themselves (the dimensions are 150 by 100), like as if you would see a test with problems in them. It will go like this:
1 2 3 4 5
6 7 8 9 10
11 12.....
Problem is when I compile this code, it will not show the objects, it will show them all in one spot (so all 25 are in same spot so you only see ONE).
Need help please.
Bookmarks