Results 1 to 3 of 3

Thread: Class type redifinition with promoted custom widgets

  1. #1

    Default Class type redifinition with promoted custom widgets

    hi,

    I usually use a custom widget of my own that inherits from QGLWidget as a rendering area for OpenGL. In Qt designer, I put a placeholder for it in my GUI an promote it to my own widget. In my GUI, there are two widgets of this type, each showing a different visualization. Then, I wanted to popup one of these widgets out of the main GUI into a separate windows(*). To do this, I created a new QMainWindows in QtDesigner and moved one widget to it (cut and paste). Now, when I compile the program, it gives a compile error that the class of my custom widget (the one being used in two QMainWindows) is being re-defined. I read the docs of Qt and some internet contributions and understood that the compiler generates the code for the classes of the widgets being promoted to. So in my case, the widget is used twice in two QMainWindows. How can I tell the designer/compiler that these widgets are the same one, so that the class is only declared once.

    Thanks,
    Zeno


    (*) The goal behind this is that I want to be able to shift this rendering widget to a second monitor and see it in the full-screen mode, while still being able to control the main GUI.

  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: Class type redifinition with promoted custom widgets

    Maybe you just forgot about protecting your widget's header file from multiple inclusion?

    Qt Code:
    1. #ifndef MY_WIDGET_H
    2. #define MY_WIDGET_H
    3. // ...
    4. #endif
    To copy to clipboard, switch view to plain text mode 
    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

    Default Re: Class type redifinition with promoted custom widgets

    Actually not. "#ifndef"s are already there.
    Last edited by zeno06; 18th June 2012 at 14:24.

Similar Threads

  1. Replies: 6
    Last Post: 3rd April 2011, 11:15
  2. Why dont see a Custom Widget Promoted ?
    By tonnot in forum Newbie
    Replies: 1
    Last Post: 27th October 2010, 13:24
  3. Promoted widgets in Qt Designer
    By martinb0820 in forum Qt Tools
    Replies: 1
    Last Post: 9th June 2010, 15:07
  4. Replies: 11
    Last Post: 14th March 2010, 22:00
  5. Promoted widgets and layout boxes
    By notsonerdysunny in forum Qt Tools
    Replies: 3
    Last Post: 2nd May 2007, 14:15

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.