Dear Sirs,
I'm designing a window which appears when information has to be entered.
This window contains a variable number of ComboBox, but when this number is to big, the window size is bigger than the screen size.
I tried to implement a scroll bar (last lines of the code bellow), but it freezes the program ??
Would someone have any idea ?
Thanks in advance,
Best Regards,
Stéphane
// Telemetry data assignment
void MainWindow::data_assignment()
{
// New window object instanciation
window_data_assignment
= new QWidget;
...
...
...
...
// Data input assigment sub-widget creation
data_assigment_input
= new QWidget;
// Label displayed of the combobox
// Combo box // if column_number if a constant
// QComboBox *ComboBox[columns_number];
// Combo box // if column_number if a constant
// this will have to be release by using delete []comboBox;
// delete []comboBox;
// GRID LAYOUT declaration
// GRID LAYOUT INSTANTIATION
// Data assigmnent window filling with input sub-widgets
for (unsigned int row = 0; row < columns_number; row++)
{
Label
= new QLabel(tr
("Data type of column # ")+QString::number(row
+1)+" :");
// Combo box data filling
for (unsigned int i = 0; i<DATA_TYPE_NB; i++)
ComboBox[row]->addItem(tr(DATA_TYPE[i]));
grid->addWidget(Label, row, 0);
grid->addWidget(ComboBox[row], row, 1);
}
//
data_assigment_input->setLayout(grid);
// Quit push button creation
// quit->setFont(QFont("Times", 18, QFont::Bold));
// Connection between widgets
connect(quit, SIGNAL(clicked()), window_data_assignment, SLOT(close()));
// Size/Position auto-managment by QVBoxLayout
wlayout->addWidget(data_assigment_input);
wlayout->addWidget(quit);
// Window scrolling
// Adding a scroll area
// scrollArea->setWidgetResizable(true);
scrollArea->setWidget(window_data_assignment);
wlayout->addWidget(scrollArea);
window_data_assignment->setLayout(wlayout);
}
// Telemetry data assignment
void MainWindow::data_assignment()
{
// New window object instanciation
window_data_assignment = new QWidget;
...
...
...
...
// Data input assigment sub-widget creation
QWidget *data_assigment_input;
data_assigment_input = new QWidget;
// Label displayed of the combobox
QLabel *Label;
// Combo box // if column_number if a constant
// QComboBox *ComboBox[columns_number];
// Combo box // if column_number if a constant
// this will have to be release by using delete []comboBox;
QComboBox** ComboBox = new QComboBox*[columns_number];
// delete []comboBox;
// GRID LAYOUT declaration
QGridLayout *grid;
// GRID LAYOUT INSTANTIATION
grid = new QGridLayout;
// Data assigmnent window filling with input sub-widgets
for (unsigned int row = 0; row < columns_number; row++)
{
Label = new QLabel(tr("Data type of column # ")+QString::number(row+1)+" :");
ComboBox[row] = new QComboBox;
// Combo box data filling
for (unsigned int i = 0; i<DATA_TYPE_NB; i++)
ComboBox[row]->addItem(tr(DATA_TYPE[i]));
grid->addWidget(Label, row, 0);
grid->addWidget(ComboBox[row], row, 1);
}
//
data_assigment_input->setLayout(grid);
// Quit push button creation
QPushButton *quit = new QPushButton(tr("OK"));
// quit->setFont(QFont("Times", 18, QFont::Bold));
// Connection between widgets
connect(quit, SIGNAL(clicked()), window_data_assignment, SLOT(close()));
// Size/Position auto-managment by QVBoxLayout
QVBoxLayout *wlayout = new QVBoxLayout;
wlayout->addWidget(data_assigment_input);
wlayout->addWidget(quit);
// Window scrolling
// Adding a scroll area
QScrollArea *scrollArea = new QScrollArea;
// scrollArea->setWidgetResizable(true);
scrollArea->setWidget(window_data_assignment);
wlayout->addWidget(scrollArea);
window_data_assignment->setLayout(wlayout);
}
To copy to clipboard, switch view to plain text mode
Bookmarks