Hi,
I am trying do some left side show/hide panel in my widget.
I have widget with left and right area. Where is posible minimalize those areas. And I want minimalize those areas to center(separator).

something like this
Qt Code:
  1. (two widget - left and right, in center some separator)
  2. ----------------------
  3. |M | M |
  4. | | |
  5. | | |
  6. ----------------------
  7. where M is minimalize button, after click left minimalize button it should look like this
  8. --------------
  9. | M | M |
  10. | | |
  11. | | |
  12. --------------
To copy to clipboard, switch view to plain text mode 

Actualy I have problem with flickering if I minimalize left area(minimalize right area isnt problem)

Whole widget has QGridLayout, where on first line are buttons, on second line some scroll area(, in center separator). It has Constrain QLayout::SetMinAndMaxSize, becouse I need fixed size.


Source part
//minimum code... but with "bad look"- blinking, "blink" part of old size wiget
Qt Code:
  1. void CustomWidget::leftSHButtonClicked()
  2. {
  3. if(m_leftAreaVisible) {
  4. //state is show, change to hide -> move widget right, decrease size
  5. move(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
  6. m_leftSHButton->switchToHide();
  7. m_leftAreaVisible = false;
  8. }
  9. else {
  10. //state is hide, change to show -> move widget left, increase size
  11. move(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
  12. m_leftSHButton->switchToShow();
  13. m_leftAreaVisible = true;
  14. }
  15. }
To copy to clipboard, switch view to plain text mode 


//Minimalize left area on click - this do less blinking...(flickering)
Qt Code:
  1. void CustomWidget::leftSHButtonClicked()
  2. {
  3. QRect r = rect();
  4. int frameTopPanelWidth = (frameGeometry().width() - width())/2;
  5. int frameTopPanelHeight = frameGeometry().height() - height() - frameTopPanelWidth;
  6.  
  7. if(m_leftAreaVisible) {
  8. //state is show, change to hide -> move widget right, decrease size
  9.  
  10. setMaximumWidth( r.width() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()));
  11. setMinimumWidth( maximumWidth());
  12.  
  13. move(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
  14.  
  15. m_layout->setGeometry(QRect(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()) + frameTopPanelWidth, y() + frameTopPanelHeight, r.width() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), r.height() ));
  16. m_leftSHButton->switchToHide();
  17.  
  18. m_leftAreaVisible = false;
  19. }
  20. else {
  21. //state is hide, change to show -> move widget left, increase size
  22.  
  23. move(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
  24.  
  25. m_layout->setGeometry(QRect(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()) + frameTopPanelWidth, y() + frameTopPanelHeight, r.width() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), r.height() ));
  26. m_leftSHButton->switchToShow();
  27.  
  28. m_leftAreaVisible = true;
  29. }
  30. }
To copy to clipboard, switch view to plain text mode 

I tryied a lot...
giving to code (to start , to end...)
Qt Code:
  1. setUpdatesEnabled(false);
  2. m_layout->setEnabled ( false );
  3. hide();
  4. QCoreApplication::sendPostedEvents ();
  5. m_layout->activate();
  6. setGeomerty instead of m_layout->setGeometry
To copy to clipboard, switch view to plain text mode 

The hide() ... show() looked good, but it do "blick", it is here some posibility to do it quick? Some kind of do it in background, and then paint?

Like problem looks that I am not able do resize and move at once due layout.
Layout resize, widget move, not posible at once?
Do anyone know how move and resize at one, or how solve this flickering?