Results 1 to 5 of 5

Thread: How to resize a widget inside my centralWidget()?

  1. #1
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to resize a widget inside my centralWidget()?

    Hello!

    I have created a QMainWidget using Qt's designer, wich has a centralWidget. The Layout of the centralWidget is set to grid-layout and resizing in the designer prview is doing well.

    Then I have created a second Widget using the designer, which contains a frame and some other widgets. Layout is set to grid and resizing is doing well too in the designer preview.

    And even resizing the MainWindow in my application is doing well too.

    My problem now is, that my second widget - the one I like to show inside the centralWidget - don't resize if I resize my Mainwindow.

    Qt Code:
    1. Home::Home ( MainWindow *pMainWindow )
    2. : myMainWindow( pMainWindow )
    3. {
    4. frameHome = new QFrame( myMainWindow->centralwidget );
    5.  
    6. setupUi( frameHome );
    7. }
    To copy to clipboard, switch view to plain text mode 

    What's wrong with that, why I cant resize the widget inside centralWidget?

    I'm sure, it's a very simple thing but I can't figure it out.

    May be it's to hot today ...

    Thanks in advance.

    Guenther
    Davao City, Philippines, Planet Earth, 35.3 °C

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to resize a widget inside my centralWidget()?

    Add a layout to your central widget if it doesn't have one and place your frame inside that layout.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to resize a widget inside my centralWidget()?

    Hello wysota,

    Quote Originally Posted by wysota View Post
    Add a layout to your central widget if it doesn't have one and place your frame inside that layout.
    that was my idea too, so I've tried it in many ways already but it don't work for me.

    I have attached two screenshots.

    For me it looks like, the centralWidget() has a layout. So I've tried this for example:

    Qt Code:
    1. frameHome = new QWidget( myMainWindow->centralWidget() );
    2. setupUi( frameHome );
    To copy to clipboard, switch view to plain text mode 

    I can resize the centralWidget, but not the content inside the centralWidget.

    I guess, I understand something totally wrong ....
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to resize a widget inside my centralWidget()?

    It may have a layout but you are not adding your widget to it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jan 2008
    Location
    Davao City, Philippines
    Posts
    77
    Thanks
    16
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to resize a widget inside my centralWidget()?

    Quote Originally Posted by wysota View Post
    It may have a layout but you are not adding your widget to it.
    wysota, you are the greatest!!!!

    I've added one line to my code and now it's working.

    Qt Code:
    1. frameHome = new QWidget( myMainWindow->centralWidget() );
    2. myMainWindow->gridLayout->addWidget(frameHome, 0, 0, 1, 1);
    3. setupUi( frameHome );
    To copy to clipboard, switch view to plain text mode 

    Thanks again for giving me the right idea.

    Have a nice day.
    Last edited by gboelter; 4th December 2009 at 10:27. Reason: updated contents

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Resize widget force layout resizing
    By ^NyAw^ in forum Qt Programming
    Replies: 17
    Last Post: 11th February 2009, 11:27
  3. Custom Widget inside a QVboxLayout
    By nemesis in forum Qt Programming
    Replies: 5
    Last Post: 25th June 2008, 14:55
  4. Replies: 5
    Last Post: 25th May 2008, 08:22
  5. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00

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.