Results 1 to 4 of 4

Thread: Child Widgets In MainWindow

  1. #1
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Exclamation Child Widgets In MainWindow

    I have created a custom MainWindow from QMainWindow and a custom widget from QGraphicsView. I'm trying to use a QGridLayout in MainWindow and place my custom widget in it. However, when I use the following in the MainWindow constructor:

    Layout = new QGridLayout();
    Layout->addWidget(CktArea);
    setLayout(Layout);

    The widget does not seem to appear anywhere.

    If I also include at the botton of the previous code:

    CktArea->show();

    The widget shows up, but in another window that has a different menu bar than the MainWindow. Also, if I wanted to hide a widget, how would that work as well?

    Thank you!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Child Widgets In MainWindow

    you need to create a widget then place on this widget your QGridLayout and the set this widget as centarl widget for QMainWindow.

  3. The following user says thank you to spirit for this useful post:

    RY (4th October 2008)

  4. #3
    Join Date
    Sep 2008
    Posts
    18
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Talking Re: Child Widgets In MainWindow

    That seems so round about. Just curious, why does it have to be done that way? :P

  5. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Child Widgets In MainWindow

    it's not a work-around. at first all layouts in Qt are not widgets, but they keep track of resizing them. QMainWindow also has own layout binder for toolbar, dockwidget etc. so, when you create a widget(A) or a dialog you must put a layout on it for enabling it to properly resize the widget(A) and widgets in the layout. the same situation in QMainWindow, but as for the widget(A) it is a central widget which you must add to QMainWindow.

Similar Threads

  1. hello! i have a simple child widgets question
    By ht1 in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2007, 00:49
  2. setClipPath on child widgets.
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 27th May 2007, 20:12
  3. scrolled widgets containers in Mainwindow
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2006, 15:40
  4. initialize child widgets within parent?
    By ucomesdag in forum Newbie
    Replies: 6
    Last Post: 6th June 2006, 09:11
  5. Replies: 2
    Last Post: 22nd February 2006, 15:58

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.