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


Qt Code:
  1. // Telemetry data assignment
  2. void MainWindow::data_assignment()
  3. {
  4. // New window object instanciation
  5. window_data_assignment = new QWidget;
  6.  
  7. ...
  8. ...
  9. ...
  10. ...
  11.  
  12. // Data input assigment sub-widget creation
  13. QWidget *data_assigment_input;
  14. data_assigment_input = new QWidget;
  15.  
  16. // Label displayed of the combobox
  17. QLabel *Label;
  18. // Combo box // if column_number if a constant
  19. // QComboBox *ComboBox[columns_number];
  20.  
  21. // Combo box // if column_number if a constant
  22. // this will have to be release by using delete []comboBox;
  23. QComboBox** ComboBox = new QComboBox*[columns_number];
  24. // delete []comboBox;
  25.  
  26.  
  27. // GRID LAYOUT declaration
  28. QGridLayout *grid;
  29.  
  30.  
  31. // GRID LAYOUT INSTANTIATION
  32. grid = new QGridLayout;
  33.  
  34. // Data assigmnent window filling with input sub-widgets
  35. for (unsigned int row = 0; row < columns_number; row++)
  36. {
  37. Label = new QLabel(tr("Data type of column # ")+QString::number(row+1)+" :");
  38.  
  39. ComboBox[row] = new QComboBox;
  40.  
  41. // Combo box data filling
  42. for (unsigned int i = 0; i<DATA_TYPE_NB; i++)
  43. ComboBox[row]->addItem(tr(DATA_TYPE[i]));
  44.  
  45. grid->addWidget(Label, row, 0);
  46. grid->addWidget(ComboBox[row], row, 1);
  47. }
  48.  
  49. //
  50. data_assigment_input->setLayout(grid);
  51.  
  52.  
  53.  
  54. // Quit push button creation
  55. QPushButton *quit = new QPushButton(tr("OK"));
  56. // quit->setFont(QFont("Times", 18, QFont::Bold));
  57.  
  58. // Connection between widgets
  59. connect(quit, SIGNAL(clicked()), window_data_assignment, SLOT(close()));
  60.  
  61. // Size/Position auto-managment by QVBoxLayout
  62. QVBoxLayout *wlayout = new QVBoxLayout;
  63. wlayout->addWidget(data_assigment_input);
  64. wlayout->addWidget(quit);
  65.  
  66.  
  67.  
  68. // Window scrolling
  69. // Adding a scroll area
  70. QScrollArea *scrollArea = new QScrollArea;
  71. // scrollArea->setWidgetResizable(true);
  72. scrollArea->setWidget(window_data_assignment);
  73.  
  74. wlayout->addWidget(scrollArea);
  75.  
  76. window_data_assignment->setLayout(wlayout);
  77.  
  78. }
To copy to clipboard, switch view to plain text mode