Hi,

Operating System: Ubuntu, Qt Version 4.3

I've got problems resizing a QToolBox to its contents. I created a QToolBox and added to each tab a QWidget, each has a different height (width is the same). At the beginning every tab of the QToolBox adjusts to the size of the Widget and displays it correctly (without scrollbar, space...). One QWidget contains a QTableWidget, which is dynamic, that means I can choose if just one row is displayed or two, your three... (by pressing a QPushbutton) At the beginning there are 8 rows. If pressing the button, a signal is emitted and the method updateSegments() should now adjust the size of the QToolBox Tab to the new size of the QTableWidget. Unfortunately this doesn't happen.
I wonder if I have the wrong QSizePolicy, etc.. I tried with adjustSize(), resize()... in updateSegments().
Has anybody a clue how to solve the problem?

Thank you!!!

I attach part of the code:
Qt Code:
  1. initializeControlBox()
  2. {
  3. controlBox = new QGroupBox();
  4. controlBox->setFixedWidth(325);
  5.  
  6. m_pTabControl = new QToolBox(controlBox);
  7.  
  8. m_pArmconfig = new QWidget();
  9. m_pTabControl->addItem(m_pArmconfig, tr("Arm Configuration"));
  10.  
  11. m_pToolLayoutVertical = new QVBoxLayout();
  12. m_pToolLayoutVertical->addWidget(m_pTabControl);
  13. m_pToolLayoutVertical->setAlignment(m_pTabControl, Qt::AlignTop);
  14. controlBox->setLayout(m_pToolLayoutVertical);
  15.  
  16. //Widget Arm Configuration
  17. m_pSegLayout = new QGridLayout();
  18.  
  19. m_pNumberSeg = new QLabel("Number of segments");
  20. m_pSelectSeg = new QSpinBox();
  21. m_pSelectSeg->setMaximum(8);
  22. m_pSelectSeg->setMinimum(3);
  23. m_pSelectSeg->setValue(8);
  24. m_pApplySeg = new QPushButton("Apply Segments");
  25. m_pApplySeg->setFixedWidth(110);
  26.  
  27. m_pSelectSegLayout = new QGridLayout();
  28. m_pSelectSegLayout->addWidget(m_pNumberSeg, 0, 0);
  29. m_pSelectSegLayout->addWidget(m_pSelectSeg, 0, 1);
  30. m_pSelectSegLayout->setVerticalSpacing(5);
  31. m_pSelectSegLayout->addWidget(m_pApplySeg, 1, 1);
  32. m_pSelectSegLayout->setAlignment(m_pApplySeg, Qt::AlignRight);
  33.  
  34. // QTableWidget
  35. m_pSegTable = new QTableWidget();
  36. m_pSegTable->setRowCount(8);
  37. m_pSegTable->setColumnCount(4);
  38.  
  39. vboxConfig = new QVBoxLayout();
  40. vboxConfig->addItem(m_pSelectSegLayout);
  41. vboxConfig->addSpacing(10);
  42. vboxConfig->addWidget(m_pSegTable,0, 0);
  43. m_pArmconfig->setLayout(vboxConfig);
  44. }
  45.  
  46. updateSegments() {
  47. m_numberseg = m_pSelectSeg->value();
  48. if (m_numberseg == 3)
  49. {
  50. //hide table rows
  51. m_pSegTable->setRowHidden(0, false);
  52. m_pSegTable->setRowHidden(1, false);
  53. m_pSegTable->setRowHidden(2, false);
  54.  
  55. for (int i=3; i<8; i++)
  56. {
  57. m_pSegTable->setRowHidden(i, true);
  58. }
  59. }
  60. }
To copy to clipboard, switch view to plain text mode