Hi,

I have problem when change the layout dynamicly.
The layout seems not be changed.

I had a look for the example already. But in my case it doesn't work. I post my code here:

One and the only one method in constructor:
Qt Code:
  1. void xyzWidget::create(bsDoubleMode mode, double minimum, double maximum, bool periodic, bool horizontal)
  2. {
  3. setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  4. if(horizontal)
  5. setLayout(new QHBoxLayout(this));
  6. else
  7. setLayout(new QVBoxLayout(this));
  8.  
  9. layout()->setMargin(0);
  10.  
  11. w_xyzGroupBox = new QGroupBox(this);
  12. w_xyzGroupBox->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
  13. if(horizontal)
  14. w_xyzGroupBox->setLayout(new QHBoxLayout(w_xyzGroupBox));
  15. else
  16. w_xyzGroupBox->setLayout(new QVBoxLayout(w_xyzGroupBox));
  17. w_xyzGroupBox->hide();
  18.  
  19. w_xValue = new bsDoubleWidget(this, mode, minimum, maximum, periodic);
  20. w_xValue->setLabel(tr("X :"));
  21. w_xValue->setLabelColor(QColor(200, 0, 0));
  22. connect(w_xValue, SIGNAL(valueChanged(double)), this, SLOT(xyzChanged(double)));
  23. connect(w_xValue, SIGNAL(editingBegin()), this, SIGNAL(xyzEditingBegin()));
  24. connect(w_xValue, SIGNAL(editingFinished()), this, SIGNAL(xyzEditingFinished()));
  25. layout()->addWidget(w_xValue);
  26.  
  27. w_yValue = new bsDoubleWidget(this, mode, minimum, maximum, periodic);
  28. w_yValue->setLabel(tr("Y :"));
  29. w_yValue->setLabelColor(QColor(0, 200, 0));
  30. connect(w_yValue, SIGNAL(valueChanged(double)), this, SLOT(xyzChanged(double)));
  31. connect(w_yValue, SIGNAL(editingBegin()), this, SIGNAL(xyzEditingBegin()));
  32. connect(w_yValue, SIGNAL(editingFinished()), this, SIGNAL(xyzEditingFinished()));
  33. layout()->addWidget(w_yValue);
  34.  
  35. w_zValue = new bsDoubleWidget(this, mode, minimum, maximum, periodic);
  36. w_zValue->setLabel(tr("Z :"));
  37. w_zValue->setLabelColor(QColor(0, 0, 200));
  38. connect(w_zValue, SIGNAL(valueChanged(double)), this, SLOT(xyzChanged(double)));
  39. connect(w_zValue, SIGNAL(editingBegin()), this, SIGNAL(xyzEditingBegin()));
  40. connect(w_zValue, SIGNAL(editingFinished()), this, SIGNAL(xyzEditingFinished()));
  41. layout()->addWidget(w_zValue);
  42. }
To copy to clipboard, switch view to plain text mode 

After I push a button, it is supposed to change the layout by calling this method:
Qt Code:
  1. void xyzWidget::setLayoutVertical()
  2. {
  3. layout()->removeWidget(w_xValue);
  4. layout()->removeWidget(w_yValue);
  5. layout()->removeWidget(w_zValue);
  6.  
  7. setLayout(new QVBoxLayout());
  8. w_xyzGroupBox->setLayout(new QVBoxLayout(w_xyzGroupBox));
  9.  
  10. layout()->addWidget(w_xValue);
  11. layout()->addWidget(w_yValue);
  12. layout()->addWidget(w_zValue);
  13. }
To copy to clipboard, switch view to plain text mode 

(The groupbox will not be used any way)

Anyone can help?