The Ultimate Qt Community site
Home News Forum Wiki Contest FAQ Links

Go Back   Qt Centre Forum > Qt > Qt Programming

Qt Programming General Qt programming issues.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 6th May 2008, 00:22
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default QStackedWidget layout problem
Related to: Qt4

Hello
I have a QStackedWidget with four pages all of which have layouts. I have created this using Designer.

What I am finding though is that when the application is run, the stacked widget takes on the dimensions of whatever page was current when the ui file was created. Ideally I would like all the pages to be the same size. They look the same size in designer, just not when the application is run.

Any help with this??

Reply With Quote
  #2  
Old 12th May 2008, 01:45
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: QStackedWidget layout problem

Hello
Is anyone able to help me - I seem to remember a post on this problem before but have been unable to find it.
Thanks

Reply With Quote
  #3  
Old 12th May 2008, 07:52
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,033
Thanks: 3
Thanked 1,554 Times in 1,507 Posts
Default Re: QStackedWidget layout problem

What you describe is not a natural behaviour - the stacked widget should have the size of the largest of its widgets and all the other widgets should adjust to it. If you observe a different behaviour, it might mean you forgot to apply a layout somewhere (for instance in the parent of the stacked widget).

Reply With Quote
  #4  
Old 13th May 2008, 00:39
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: QStackedWidget layout problem

Hello
Thanks for that. I have looked for missing layouts but can't see any. I've attached a copy of the ui file and would appreciate it if you would have a look.

I am using Designer to contruct the basic interface.

Thanks
Attached Files
File Type: zip mainWindow.zip (5.8 KB, 3 views)

Reply With Quote
  #5  
Old 13th May 2008, 06:58
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,033
Thanks: 3
Thanked 1,554 Times in 1,507 Posts
Default Re: QStackedWidget layout problem

I don't see the effect you experience. For me the stacked widget remains the same regardless of which page is currently being displayed.

Reply With Quote
  #6  
Old 13th May 2008, 08:09
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: QStackedWidget layout problem

Thanks for looking at it - must be a problem with my Python code.

Given that I am stumped on this, can you give me any general pointers as to how to find the offending bit. I do not specify/delete layouts in my Python code. I am adding dock widgets top, right and bottom.

Thanks again

Reply With Quote
  #7  
Old 14th May 2008, 01:09
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Unhappy Re: QStackedWidget layout problem

I have explored a little further and found the following:

1) The pages all size correctly in Designer

2) I have cut my Python code right down and the same problem still occurs when the application is run - ie the only page that shows correctly is the page that was current when saving the ui file (and then using pyuic4 to create the python file).

Here is my cut down code.

class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow,self).__init__(parent)

self.setupUi(self)
self.pgSurvey.show() # non current page in stacked widget


def main():
app = QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())

main()

so I am assuming that the ui file is correct as Wysota says.

Any suggestions as I am stumped on this.

Thanks

Reply With Quote
  #8  
Old 14th May 2008, 02:18
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: QStackedWidget layout problem

Hello again

I found my problem - I was not setting currentIndex of the stackwidget for each page. Works a treat now !

Reply With Quote
  #9  
Old 14th May 2008, 07:15
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,033
Thanks: 3
Thanked 1,554 Times in 1,507 Posts
Default Re: QStackedWidget layout problem

"self.pgSurvey.show()" - this is wrong. Let the stacked widget control the visibility of its widgets.

Reply With Quote
The following user says thank you to wysota for this useful post:
Banjo (15th May 2008)
  #10  
Old 15th May 2008, 00:15
Banjo Banjo is offline
Novice
 
Join Date: Jan 2008
Qt products used: Qt4
Qt platforms used: Windows
Posts: 26
Thanks: 5
Thanked 0 Times in 0 Posts
Default Re: QStackedWidget layout problem

Yes thanks Wysota - I discovered that after rereading the documentation!!

Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Layout Problem sabonis Qt Designer 4 3rd March 2008 20:57
problem with Tool button n Layout arjunasd Qt Designer 11 24th July 2007 21:14
QStackedWidget fill Postscript image And scroll problem patrik08 Qt Programming 11 22nd April 2007 09:30
Grid Layout Problem Seema Rao Qt Programming 2 4th May 2006 12:45
Layout Problem Seema Rao Qt Programming 4 19th April 2006 11:08


All times are GMT +1. The time now is 19:31.

Powered by vBulletin Version 3.7.1 Copyright ©2000 - 2008, Jelsoft Enterprises Ltd., vRewrite 1.5 SEOed URLs completed by Tech Help Forum and Chalo Na.
© 2006–2008 Qt Centre - The Ultimate Qt Community site
The Qt by Trolltech logo is used with express permission of Trolltech ASA. Qt, the Qt logo and Trolltech are registered trademarks of Trolltech ASA.