PDA

View Full Version : problem with QStackedwidget



psantofe
13th April 2010, 11:14
My problem is the following:
suppose that I set two windows; I'd like to switch from one to each other using a Pushbutton.
First, I set QStackedWidget with the default two pages: in every page I set my switch button.
My final application must be 800x480 because I use it on a 7" touchscreen LCD.
First windows opened when my application starts, has no problem; when I pressed the button, the second window appeared horizontally truncated after 640 pixel.
I close my application and start it again using my second window as first visible window: this appears correct and when I press the button to switch to the other one, this last appears horizontally truncated exactly after 640 pixel (same as previously observed on the other window).
It seems starting window is OK, meanwhile the second one selected pressing the button is wrong.
I tried to set size policy to expand: nothing to do!
I tried to set size policy to maximum: nothing to do!!
At the end my first appearance is correctly 800x480, meanwhile when I switch to the following stacked window the new appearance is 640x480.
Last annotation: coming back to the first starting window dimension is still 800x480.
So I'm losting in the deeper Qt ocean!!! SaveMySoul!!
What can I should do?
Paolo
Qt 4.6.2 on Ubuntu Karmic Koala

faldzip
13th April 2010, 11:23
What can I should do?

First of all, show us your code so we can see what have you already tried.

psantofe
13th April 2010, 11:45
I developed my application using Qt Creator 1.3.1. I could include some files. In my opinion problem could be located in ui file, so I could show ui_myfile.h or myfile.ui.
Wait for your question
Paolo

psantofe
14th April 2010, 13:41
Solved! I set SetGeometry() property inside my code. See the code:
void MiaQStackedWidget::on_pushButton_pressed()
{
ui->page_1->hide();
ui->page_2->setGeometry(0,0,800,480);
ui->page_2->show();
}
I tought Geometry was already set inside QtCreator, but it wasn't so. I tried and all my pages now are correctly sized as I like.
I don't know if it's the best method, there're further ways to obtain same result, but I see It works and I'm ok.
Paolo