Results 1 to 6 of 6

Thread: Promoting widget in Designer

  1. #1
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Promoting widget in Designer

    Hi everybody,

    I am working on a project for which I have designed the user interface in the Designer.

    I now want to add a too bar above my QGraphicsView. For this I would like to use QToolBar.

    Unfortunately I can't add a QToolBar directly in the designer, so I just added a "Widget" where I want the toolbar to be placed. I then created a class "ToolBar2D", which inherits from QToolBar.

    Now I have found out that I can promote widgets to user-defined classes. So I right-clicked the Widget in the designer and clicked on "Promote to..."

    Then a window opened where I tried to add the class:

    Base-Class: QToolBar
    Class-name: ToolBar2D
    Include-File: toolbar2d.h
    Global include file: checked

    I can then click the button to add this class, but the "Promote" button is disabled. And in the list above the class is added but it says "not used"

    (all the terms I wrote were translated since my Designer is in German)...

    Can anybody tell me why this isn't working? Why is the added class not accepted?

    Would be great if anyone could help me!

    Thanks,
    -evident-

  2. #2
    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: Promoting widget in Designer

    In the designer you have inserted a QWidget, so you can only promote classes which have QWidget as base. So simply tell designer QWidget is the base class of your ToolBar2D.

  3. #3
    Join Date
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Promoting widget in Designer

    Ahh ok thank you... This of course makes sense! Working...

  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: Promoting widget in Designer

    Or better yet put your graphics view into QMainWindow and use the regular toolbar features from Designer.
    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
    Jul 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Promoting widget in Designer

    Well since I don't just have the QGraphicsView and the toolbar this won't work... there are two Toolbars, one for the QGraphicsView below and one for a QGLWidget... and there also is other stuff.... but thanks for the tip...

  6. #6
    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: Promoting widget in Designer

    Quote Originally Posted by evident View Post
    Well since I don't just have the QGraphicsView and the toolbar this won't work...
    Sure it will. If you want, you can always place a QMainWindow into another widget. If you use a plain QToolBar without a QMainWindow (I sometimes do that as well), it has its down sides, like not being able to move toolbars around, closing them, etc.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 6th May 2010, 10:09
  2. Replies: 3
    Last Post: 10th December 2009, 22:53
  3. Promoting QLabel
    By anafor2004 in forum Qt Tools
    Replies: 23
    Last Post: 28th January 2008, 11:27
  4. Error when promoting a custom widget
    By engin in forum Qt Tools
    Replies: 1
    Last Post: 15th December 2006, 16:00
  5. Promoting a custom widget derived from QWidget Qt4
    By high_flyer in forum Qt Tools
    Replies: 1
    Last Post: 2nd March 2006, 18:50

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.