Results 1 to 5 of 5

Thread: QWidget container / Promote a widget without using Creator or Designer

  1. #1
    Join Date
    Aug 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QWidget container / Promote a widget without using Creator or Designer

    I have recently switched to designing my GUIs and all code in a text editor since I prefer writing in VIM and I often prefer working without X.

    I'll try and keep this short and bulletpoint like.

    I have hit one snag though that I cannot find any documentation on (Please correct me if I am wrong).

    I have a QWT plot (this is not QWT specific, so I am posting here) that I want to include in my QVBoxLayout as part of the MainWindow.

    The issue is that when I add the VBoxLayout to a QWidget window and then do window->show() the VBox appears as a new window.

    I have set the background of the application to the Dark palette and the original window has the affected background colour but the Plot and anything in the VBox appears as a new window.

    How do I get the QVBoxLayout to appear as part of the main window?


    Thank you!

    -Gavin

  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: QWidget container / Promote a widget without using Creator or Designer

    You are missing a layout on some level, most probably your VBoxLayout's parent widget is not placed in a layout.

    I have no idea why does the title of this thread refer to promoting widgets, though.
    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
    Aug 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget container / Promote a widget without using Creator or Designer

    The reason I used the terminology of promoting widgets is that that is what I did to obtain the same result in Creator.

    Create a widget on the form -> promote widget -> include header + class name and it then appeared on the main window.

    Thank you for your suggestion regarding adding parent widget. I will try that now!

  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: QWidget container / Promote a widget without using Creator or Designer

    Quote Originally Posted by Gavin Harper View Post
    The reason I used the terminology of promoting widgets is that that is what I did to obtain the same result in Creator.
    From what I understand you just want to use a custom widget. But it has nothing to do with your problem. You'd be having the same problem if you wanted to use QPushButton or any of the other widget classes. Your C++ code is simply incorrect.
    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
    Aug 2010
    Posts
    28
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWidget container / Promote a widget without using Creator or Designer

    Solved.

    I was adding my layout to a QWidget and doing widget->show(); instead of setCentralWidget(widget);

Similar Threads

  1. Designer: How to promote to a existing Qt Widget?
    By nightghost in forum Qt Programming
    Replies: 2
    Last Post: 9th December 2009, 09:12
  2. Replies: 3
    Last Post: 17th November 2009, 14:43
  3. how to promote layout in Designer?
    By homerli in forum Qt Tools
    Replies: 1
    Last Post: 11th May 2009, 16:40
  4. QFormBuilder+Designer's Promote to ...
    By OriginalCopy in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2007, 16:43
  5. Replies: 4
    Last Post: 9th August 2007, 08:20

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.