Results 1 to 18 of 18

Thread: Ui file loaded by UiLoader , but NULL pointer to custom widgets

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    it is custom widget plugin for QtDesigner and contains Q_EXPORT_PLUGIN2(customwidgetplugin, QLedPlugin) .

  2. #2
    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: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    you didn't answer my question, did you understand what I asked?
    ==========================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
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    QLed is a custom widget in QLed.h file exist :
    class QDESIGNER_WIDGET_EXPORT QLed : public QWidget
    Is this your answer !!??

  4. #4
    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: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    Partly.
    This define either will expand to __declspec( dllimport ) or __declspec( dllexport ), depending if you define the define variable in your plugin project.
    In your plugin you should have a header with something like:
    Qt Code:
    1. #if defined(FOO_LIBRARY)
    2. # define FOOSHARED_EXPORT Q_DECL_EXPORT
    3. #else
    4. # define FOOSHARED_EXPORT Q_DECL_IMPORT
    5. #endif
    To copy to clipboard, switch view to plain text mode 

    and you have to define FOO_LIBRARY in your plugin project, otherwise the class doesn't get exported.
    ==========================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.

  5. #5
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    Hello high_flyer, thanks for replies,
    Dear Sir, Qts manual says i can design a custom widget and make a dll also plugin export what it need, and use it in QtDesigner, i think you say i make new other dll for using in QtCreator, but then is it possible two dll and same QLed class??

    i also tested this on Q3Frame it is a custom widget plugin in QtDesigner and same problem.

  6. #6
    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: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    did you find in your project the code I posted in my last post?
    ==========================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.

  7. #7
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    in custom widgets have not any
    //////////////////
    __declspec( dllimport ) or __declspec( dllexport )

    #if defined(FOO_LIBRARY)
    # define FOOSHARED_EXPORT Q_DECL_EXPORT
    #else
    # define FOOSHARED_EXPORT Q_DECL_IMPORT
    #endif
    ///////////////////////

    my project and QLed also have not,
    but my plugin has QDESIGNER_WIDGET_EXPORT "class QDESIGNER_WIDGET_EXPORT QLed : public QWidget"

  8. #8
    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: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    and to what does QDESIGNER_WIDGET_EXPORT expand to?
    In should expand to __declspec( dllimport ) under windows.
    ==========================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.

  9. #9
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    as QT manual and it's samples said custom widget plugin make by using QDESIGNER_WIDGET_EXPORT keyword.
    i can not understand how i can use QDESIGNER_WIDGET_EXPORT keyword and you said __declspec( dllimport ) to have both of them.
    Thanks in Advanced

  10. #10
    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: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    try adding this to your QLed.h

    Qt Code:
    1. #if defined(QLED_LIBRARY) //this should be defined in your preprocessor when you build the plugin
    2. # define QDESIGNER_WIDGET_EXPORT Q_DECL_EXPORT
    3. #else
    4. # define QDESIGNER_WIDGET_EXPORT Q_DECL_IMPORT //this will be defined on the user application side. You don't need to do anything for that.
    5. #endif
    To copy to clipboard, switch view to plain text mode 

    if it didn't help you will have to read about how to export\import classes over DLLs.
    http://doc.qt.nokia.com/4.7-snapshot/sharedlibrary.html
    It looks like you are not importing your QLed library.
    ==========================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.

  11. The following user says thank you to high_flyer for this useful post:

    serjik (24th May 2011)

  12. #11
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets


    Thanks high_flyer
    I fix my problem by reading this link:
    http://doc.qt.nokia.com/latest/desig...a-ui-file.html
    But I didnt use UiLoader,Regards Lopez.

  13. #12
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: Ui file loaded by UiLoader , but NULL pointer to custom widgets

    Hi, ok first i compile my plugin (here QLed you can get it http://qt-apps.org/content/show.php?content=72482), after compilation i add some QLed widgets to my FORM by QDesigner, then i copy QLed.h and QLed.cpp to my own project and in QLed.h file i delete QDESIGNER_WIDGET_EXPORT keyword, and now i can access my FORM children, BUT I DIDnt do with UiLoader, (if any body can do it please modify my code and upload, thanks in advance), now you can find my test program in attachment, Regards Serjik.
    Attached Files Attached Files

Similar Threads

  1. Replies: 21
    Last Post: 8th June 2011, 08:59
  2. Replies: 33
    Last Post: 2nd December 2010, 16:47
  3. Custom QLineEdit to store NULL with QDataWidgetMapper
    By certqt in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2010, 13:15
  4. Replies: 1
    Last Post: 28th June 2010, 06:21
  5. Dereferencing a NULL Pointer for staticMetaObject?
    By hyling in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2006, 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.