PDA

View Full Version : Layout resizing problem



Yaoming
15th January 2014, 10:47
Hi, I've got this application: 9931
As you can see, I've got two PushButtons with black arrows. Those buttons are supposed to make the corresponding widget (either the tabWidget on the left or the normal widget on the right) take the entire size of the application window. I've tried to resize using the corresponding function but it's not working... I've also seen that showFullScreen() only works for independant windows...
Can you please tell me why my resize is not working? Here's what I have done so far:

ui.LayoutCahiers->setSizeConstraint(QLayout::SizeConstraint::SetNoCo nstraint); // I'm trying to destroy all constraints that may interfere with the resize function
ui.Onglets->resize(200, 500); //trying to resize with random values (just to see if it works)

Thanks for your replies.

anda_skoa
15th January 2014, 12:58
My first idea would be to use a QSplitter for the separation. It allows sections to be collapsed

Another approach would be to hide the part that should no longer be visible.

Cheers,
_

Yaoming
15th January 2014, 15:24
Thanks for your reply.
I've just realised I had understood it all wrong: when you push the button, the widget needs to be fullscreen. If I manage to make the corresponding widget an independent window and use showFullScreen() it'll be great.
Could it be possible to "detach" the widget from the main application window? And reatach it to the window afterwards?

I tried this:


ui.Onglets->setParent(0);
ui.Onglets->showFullScreen();

but it's not working :D

Added after 14 minutes:

Sorry it actually works. My connect was messing it up. I've got one more problem though, when I come back from fullscreen (using showNormal() ) my widget takes the entire page (the second is in background I guess).
How could I come back to the layout I had done?
I tried setLayout() but which layout should I take? My window layout, my widget layout? Another one I haven't thought about?

I've tried with every single layout I got in my ui, not working.

anda_skoa
15th January 2014, 16:03
You'll need to show more code.
Ideally a small example program that can be built and run to demonstrate the problem.

Cheers,
_

Yaoming
15th January 2014, 16:22
if(!widgetIsFullscreen)
{
ui.Geom->setParent(0);
ui.Geom->showFullScreen();
ui.GeomPleinEcran->setIcon(QIcon("Resources/SortieFullscreen.gif"));
widgetIsFullscreen = true;
return;
}
else
{
ui.Geom->setParent(ui.centralWidget);
ui.Geom->showNormal();
ui.GeomPleinEcran->setIcon(QIcon("Resources/Fullscreen.gif"));
widgetIsFullscreen = false;
return;
}

This is what I've done for the left widget (sorry I'm French so my attributes names are in french). Anyway, I got a boolean that is either true (if the widget is fullscreen) or false (if it isn't). I put the icon corresponding to the state of the widget (fullscreen or not). If the button is clicked, if we are in fullScreen, then we go out of it (setParent and setLayout?) if not then we toggle our fullscreen mode (setParent(0)).
Thanks for helping me :)

ChrisW67
15th January 2014, 20:17
You need to add the widget to the layout it was in before you removed and maximised it.


ui.layoutCahiers.addWidget(ui.Geom);
// or
ui.layoutCahiers.insertWidget(0, ui.Geom);

Yaoming
15th January 2014, 22:09
Thanks a lot it works perfectly now.