Results 1 to 5 of 5

Thread: Custom widgets, where must I put them ?

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

    Default Custom widgets, where must I put them ?

    I have read the tutorials (and the book - QT Gui ) about it, but in both cases (promote and plugin) I dont know where physically must I put them.
    Must I compile them ? Can I ?
    Any deep tutorial or solution ?
    Thanks

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

    Default Re: Custom widgets, where must I put them ?

    You don't have to put them in any specific place.
    You project needs to know where to find them.
    You need to compile any code to have it run. (C++)
    Maybe it will be easier if you first say what it is you are trying to do, and where you got it to trouble while trying.
    ==========================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.

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

    Default Re: Custom widgets, where must I put them ?

    From the book c++ gui ...
    Integrating Custom Widgets with Qt Designer
    Before we can use custom widgets in Qt Designer, we must make Qt Designer aware of them. There are two
    techniques for doing this: the "promotion" approach and the plugin approach.
    If I have a widget (h and cpp files) or somebody gives me this two files, how can I do this 'promotion'.
    And If I develop one special widget and want to distribute the 'exe' or 'dll' not the code, how can I do it ?

    Thanks
    Last edited by tonnot; 21st October 2010 at 17:57.

  4. #4
    Join Date
    Sep 2010
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Custom widgets, where must I put them ?

    Promoting is pretty easy. Just add the custom widget code to your Qt project. Then in the desinger, add a widget that your custom widget directly inheirits. Right-click that widget and select Promote to.. Then fill out the fields with the required header and object name for your cutom widget.

    To distrubute your stuff w/o source you'll need to:

    A. Distribute only to a machine that has the Qt libs
    or
    B. Distribute the shared libs that your widget needs to run with the .exe or dll
    or
    C. Build an all inclusive package by linking your code with the static version of Qt libs

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

    Default Re: Custom widgets, where must I put them ?

    @tonnot:
    just to make it clear:
    promoting a widget in designer, will not let you use its features.
    Its nothing more than a way to tell designer which header it should include in the ui.
    If you want to be able to add a "real" custom widget, like you can add the widget supplied with designer, you will have to write a plugin.

    Having said that, I would recommend to you to leave the designer integration until you get comfortable with creating custom widgets in general.
    (from your questions it looks like you are very much a beginner to C++ and Qt).
    Learn first how to subclass a widget, and customize it, and use it in code.
    The next step is to wrap the custom widget in a plugin or promote it in designer.
    ==========================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: 1
    Last Post: 18th July 2012, 09:59
  2. Custom Widgets in QT DEsigner
    By amitkhanna in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 06:15
  3. Custom Widgets
    By walden02 in forum Qt Programming
    Replies: 3
    Last Post: 23rd December 2009, 11:43
  4. Replies: 0
    Last Post: 15th May 2009, 15:38
  5. Help with custom widgets!!
    By superteny in forum Qt Programming
    Replies: 4
    Last Post: 29th April 2009, 12:43

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.