emil0076
13th February 2011, 20:24
Hi, I have problem with QVBoxLayout (and other Q...Layout objects).
1. I have QTabWidget, I add tab with set widget QScrollArea.
2. QScrollArea has set widget QWidget.
3. QWidget has set layout QVBoxLayout.
4. I make array of pointers to QLabel, next in "for" loop I make objects of QLabel, add pointers to array and add objects to QVBoxLayout.
(...)
QTabWidget *tabWidget;
QScrollArea *scrollArea1;
QWidget *widget1;
QLayout *layoutTab1;
QLabel **labels;
(...)
this->tabWidget = new QTabWidget();
this->scrollArea1 = new QScrollArea(this->tabWidget);
this->widget1 = new QWidget(this->scrollArea1);
this->layoutTab1 = new QVBoxLayout(widget1);
this->widget1->setLayout(this->layoutTab1);
this->scrollArea1->setWidgetResizable(true);
this->scrollArea1->setWidget(this->widget1);
this->tabWidget->insertTab(0, this->scrollArea1, tr(TAB1_));
*(this->labels) = new QLabel[10];
for(int i=0; i<=9; i++)
{
labels[i] = new QLabel(tr("TEST"));
labels[i]->setFrameStyle(1);
labels[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
this->layoutTab1->addWidget(this->labels[i]);
}
My problem is:
When number of labels is over 5 they are outside app window (scrolling in QScrollArea works perfectly) and (in debug mode) I get error after close app - "Application has stopped working". Released app doesn't run, this same error is before start. If number of QLabels is less (all can be in window) everything works good.
I think this is problem with QVBoxLayout because I comment everything except making object of QVBoxLayout, making array of objects QLabel and adding them to QVBoxLayout and problem is this same.
What's wrong? Please help.
1. I have QTabWidget, I add tab with set widget QScrollArea.
2. QScrollArea has set widget QWidget.
3. QWidget has set layout QVBoxLayout.
4. I make array of pointers to QLabel, next in "for" loop I make objects of QLabel, add pointers to array and add objects to QVBoxLayout.
(...)
QTabWidget *tabWidget;
QScrollArea *scrollArea1;
QWidget *widget1;
QLayout *layoutTab1;
QLabel **labels;
(...)
this->tabWidget = new QTabWidget();
this->scrollArea1 = new QScrollArea(this->tabWidget);
this->widget1 = new QWidget(this->scrollArea1);
this->layoutTab1 = new QVBoxLayout(widget1);
this->widget1->setLayout(this->layoutTab1);
this->scrollArea1->setWidgetResizable(true);
this->scrollArea1->setWidget(this->widget1);
this->tabWidget->insertTab(0, this->scrollArea1, tr(TAB1_));
*(this->labels) = new QLabel[10];
for(int i=0; i<=9; i++)
{
labels[i] = new QLabel(tr("TEST"));
labels[i]->setFrameStyle(1);
labels[i]->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum);
this->layoutTab1->addWidget(this->labels[i]);
}
My problem is:
When number of labels is over 5 they are outside app window (scrolling in QScrollArea works perfectly) and (in debug mode) I get error after close app - "Application has stopped working". Released app doesn't run, this same error is before start. If number of QLabels is less (all can be in window) everything works good.
I think this is problem with QVBoxLayout because I comment everything except making object of QVBoxLayout, making array of objects QLabel and adding them to QVBoxLayout and problem is this same.
What's wrong? Please help.