Results 1 to 19 of 19

Thread: Promote Qwidget problem, class already exists ???

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Promote Qwidget problem, class already exists ???

    Do you understand what promoting a widget is?
    Can you explain what it is?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default Re: Promote Qwidget problem, class already exists ???

    Yes I have read the help. And see :
    In all other cases, where the source code to the custom widgets is available, we can adapt the custom widget for use with Qt Designer.
    But ... I dont want to spent time building the plugin.
    And.... I remember (when begin to learn QT) that I could to use 'promote' to use custom widgets....

    Can you help me ?

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Promote Qwidget problem, class already exists ???

    You didn't answer my question:
    What does promoting a widget do?
    I ask, to be sure you understand what it is.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default Re: Promote Qwidget problem, class already exists ???

    As you said a time ago :
    Promoting a widget is nothing more than telling designer that it should trust you, and in the UI file, it will create the class you promoted to, and put the include file for your custom file in the ui.
    So when the ui compiler makes C++ code out of your ui, in your project where your custom class is known, it will compile and when you run the application, your gui will show your custom widget where the promoted widget is on the from.
    Ergo - in designer, at design time, designer knows nothing about your promoted widget, and it will only show the base widget it knows.
    If you want to have your custom widget "designable" in designer, you will have to create a designer plugin out of your custom widget.
    But, I cant do this ....
    I have see other posts.... 'Simply write the name of the class and the header ....' This is just what I do .... but QTCreator-Designer says me 'class already exists' ....

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Promote Qwidget problem, class already exists ???

    Lol.
    So you posted my answer - good to know I know what promotion is.
    But ok, lets go one step further:
    But, I cant do this ....
    Now if you only explain what 'this' means, we might be able to help you - what it is you are trying to achieve?
    Please note:
    I ask about the end result you are after, not the way you are trying to do it!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default Re: Promote Qwidget problem, class already exists ???

    Promote can let me to use custom widgets without building the plugin ?
    This is the main idea I have about it, I'm wrong ?

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Promote Qwidget problem, class already exists ???

    Promote can let me to use custom widgets without building the plugin ?
    This is the main idea I have about it, I'm wrong ?
    now you have answered my questions from before.
    Good.
    It depends how you mean what you said, to judge if you are wrong or not.
    Promoting allows you to use a custom widget in designer, which IS implemented in your code, but not as a designer plugin.
    Now by "use in designer" I mean, you can have a base widget of your custom widgets serve as a place holder in the form for your custom widget.
    You then "promote" the base widget to your own custom widget, so that creator will generate the right headers, and class names when it generates the ui.
    But you wont see your custom widget in designer just because you promoted a widget!
    You can only have instances of widgets that are supplied to designer via the designer plugins system.
    That is all!
    It will not save you from actually implementing your custom widget!
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Sep 2010
    Posts
    654
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    56
    Thanked 1 Time in 1 Post

    Default Re: Promote Qwidget problem, class already exists ???

    Thanks for your patience H.F.
    But.... You say :
    You then "promote" the base widget to your own custom widget, so that creator will generate the right headers, and class names when it generates the ui.
    But I can't write the correct name of my class.... (because QT says me that 'it's already exists...)
    Ok, then I see the ui_form.h code and see 'mywidget' instance. I change it to 'MyWidget' (I have MyWidget.h and MyWidget.cpp), and I build my project. Ok ! It works. But, if I re-open the .ui form, QT rewrites my ui_form.h again bad...
    I dont want to see MyWidget in designer (I know that I have to build the plugin) But I want to test it .
    If I have the h and cpp files for MyWidget.... What more must i do ?
    Thanks again-

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: Promote Qwidget problem, class already exists ???

    I have hard time understanding what it is you are doing, but you are clearly doing something you shouldn't.
    Ok, then I see the ui_form.h code and see 'mywidget' instance. I change it to 'MyWidget' (I have MyWidget.h and MyWidget.cpp), and I build my project.
    Do you mean you are changing the ui_form.h?
    If this is what you are doing you should not do it, since the uic will overwrite it each time it builds the ui file.
    If you promote your widget correctly, it will appear correctly in the ui_form.h with out the need to modify it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 0
    Last Post: 23rd November 2010, 21:54
  2. Replies: 1
    Last Post: 30th October 2010, 13:28
  3. Replies: 4
    Last Post: 27th October 2010, 17:43
  4. Replies: 7
    Last Post: 22nd September 2010, 01:32
  5. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 18th May 2008, 00:29

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
  •  
Qt is a trademark of The Qt Company.