waediowa
14th May 2008, 08:16
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
(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"- blinking, "blink" part of old size wiget
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)
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...
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?
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
(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"- blinking, "blink" part of old size wiget
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)
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...
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?