Results 1 to 6 of 6

Thread: QT layout issue

  1. #1
    Join Date
    May 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QT layout issue

    Hi,

    Currently I am designing UI of my application. I am using QT creator to design UI. UI contain tabwidget, buttons etc.
    My problem is related to layout. If i simply drop widget on form(without applying any layout), resize them according to my choice and run application then everything is ok until I resize my application window. Widget are not resized accordingly. Qt documentation suggested layout to handle resizing issue. So i used layout but after placing widgets on layout they are changing their size (tab widget is becoming small and buttons on horizontal layout stretched) and i am not able to resize them. I tried to play with "Size policy" and used "Fixed" but my widgets are not resized according to my choice.

    Will you please suggest a solution, so that i can use proper layouting?

    Thanks

  2. #2
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QT layout issue

    Ok,keep in mind that you have to call the widget's setLayout() function;

    Here's an example:
    1.Create a new ui class in QtCreator called MyWidget
    2.Open the ui file,drag a layout into MyWidget,name it "myLayout".
    3.Add stuffs to myLayout.
    4.In the constructor of MyWidget,call setLayout():
    Qt Code:
    1. MyWidget::MyWidget()
    2. {
    3. ui.setupUi(this);
    4. setLayout(ui.myLayout);
    5. }
    To copy to clipboard, switch view to plain text mode 
    It's not the goodbye that hurts,but the flashback that follow.

  3. #3
    Join Date
    May 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT layout issue

    Thanks for quick reply.

    I created new "QT designer form" derived from "widget template", placed a vertical box ;layout on form and then placed a button on it. After placing button, button was resized automatically by the effect of vertical box layout and i am not able to resize it. plz check the attached image.
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QT layout issue

    change the vertical size policy.

  5. #5
    Join Date
    May 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QT layout issue

    Thanks.
    Something is working, not completely but let me try.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QT layout issue

    Quote Originally Posted by meraj ansari View Post
    Thanks for quick reply.

    I created new "QT designer form" derived from "widget template", placed a vertical box ;layout on form and then placed a button on it. After placing button, button was resized automatically by the effect of vertical box layout and i am not able to resize it. plz check the attached image.
    You currently have a layout that is not attached to a parent container widget.

    Try this:
    • Create a blank form or widget.
    • Drop your push button on the form.
    • Select the form.
    • On the Designer tool bar select the tool for Layout Vertically. Alternately, use the option in the Form menu.

    The form now has the selected layout applied. The layouts you see in the widget palette can be placed on a form, within its existing layout, to contain more complex sub-layouts of widgets.

Similar Threads

  1. Issue with layout
    By N3wb in forum Newbie
    Replies: 2
    Last Post: 22nd September 2009, 17:01
  2. customized layout issue
    By sanjayshelke in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2008, 07:02
  3. Window Layout issue.
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 26th August 2008, 21:46
  4. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  5. Qt layout issue
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 15th August 2007, 19:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.