Saturday, August 30th 2008, 12:07pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, May 13th 2008, 4:03pm

Move and resize with layout

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

Source code

1
2
3
4
5
6
7
8
9
10
11
12
(two widget - left and right, in center some separator)
----------------------
|M            | M       | 
|             |         |
|             |         |
----------------------
where M is minimalize button, after click left minimalize button it should look like this
          --------------
         | M  | M       | 
         |    |         |
         |    |         |
          --------------


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"

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void CustomWidget::leftSHButtonClicked()
{
    if(m_leftAreaVisible) {
        //state is show, change to hide -> move widget right, decrease size
        move(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
        m_leftSHButton->switchToHide();
        m_leftAreaVisible = false;
    }
    else {
        //state is hide, change to show -> move widget left, increase size
        move(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());
        m_leftSHButton->switchToShow();
        m_leftAreaVisible = true;
    }
}



//Minimalize left area on click - this do less blinking...(flickering)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void CustomWidget::leftSHButtonClicked()
{
  QRect r = rect();
  int frameTopPanelWidth = (frameGeometry().width() - width())/2;
  int frameTopPanelHeight = frameGeometry().height() - height() - frameTopPanelWidth;

    if(m_leftAreaVisible) {
        //state is show, change to hide -> move widget right, decrease size

setMaximumWidth( r.width() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()));
setMinimumWidth( maximumWidth());

        move(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());

m_layout->setGeometry(QRect(x() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()) + frameTopPanelWidth, y() + frameTopPanelHeight, r.width() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), r.height() ));
        m_leftSHButton->switchToHide();

        m_leftAreaVisible = false;
    }
    else {
        //state is hide, change to show -> move widget left, increase size

        move(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), y());

m_layout->setGeometry(QRect(x() - (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()) + frameTopPanelWidth, y() + frameTopPanelHeight, r.width() + (m_leftArea->maximumWidth() - m_leftSHButton->maximumWidth()), r.height() ));
        m_leftSHButton->switchToShow();

        m_leftAreaVisible = true;
    }
}


I tryied a lot...

Source code

1
2
3
4
5
6
7
giving to code (to start , to end...)
//setUpdatesEnabled(false);
//m_layout->setEnabled ( false );
//hide();
//QCoreApplication::sendPostedEvents ();
//m_layout->activate();
setGeomerty instead of m_layout->setGeometry


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?

This post has been edited 3 times, last edit by "waediowa" (May 13th 2008, 4:08pm)

  • Go to the top of the page

Rate this thread