Results 1 to 20 of 22

Thread: How i can access my custom plugin when i loaded a ui file, my program crashed

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

    Red face Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    Hello, i change my pro file
    i have to extend ((# install)) part because my compiler was crashed,
    //================================================== ==========
    my test.pro file:


    QT += core gui

    CONFIG += uitools

    #LIBS += c:/QGLabelPlugin_Release.dll

    INCLUDEPATH += C:/ \
    C:/TEST/test1

    RESOURCES += test.qrc

    SOURCES += main.cpp

    #HEADERS += QGLabel.h


    # install
    target.path = C:/TEST/test1
    sources.files = $$SOURCES $$HEADERS $$RESOURCES test.pro files
    sources.path = C:/TEST/test1
    INSTALLS += target sources

    //================================================== ==========
    main.cpp

    Qt Code:
    1. #include <QApplication>
    2. #include <QUiLoader>
    3. #include <QWidget>
    4. #include <QFile>
    5. #include <QMainWindow>
    6. #include <QtGui>
    7. #include "QLabel.h"
    8. #include "QGLabel.h"//???????????????????
    9. //Qt 4.7.0
    10. int main(int argc, char **argv)
    11. {
    12. Q_INIT_RESOURCE(test);
    13.  
    14. QApplication app(argc, argv);
    15.  
    16. QUiLoader loader;
    17. QFile uiFile(":/test.ui");
    18. uiFile.open(QIODevice::ReadOnly);
    19. QWidget *ui = loader.load(&uiFile);
    20. uiFile.close();
    21.  
    22. qDebug() << loader.pluginPaths();
    23. ui->show();
    24. //after loading this form i need to access its child widgets
    25.  
    26. QList<QGLabel*> lstLabels = ui->findChildren<QGLabel*>();////////////////////////
    27.  
    28. return app.exec();
    29. }
    To copy to clipboard, switch view to plain text mode 

    //================================================== ==========
    ERROR::::::::::::::::::::::

    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o release\test.exe release/main.o release/qrc_test.o -L"c:\Qt\2010.05\qt\lib" -lmingw32 -lqtmain -lQtUiTools -lQtXml4 -lQtGui4 -lQtCore4

    release/main.o:main.cpp.text+0x304): undefined reference to `_imp___ZN7QGLabel16staticMetaObjectE'

    collect2: ld returned 1 exit status

    mingw32-make[1]: Leaving directory `C:/TEST01/test-build-desktop'

    mingw32-make: Leaving directory `C:/TEST01/test-build-desktop'

    mingw32-make[1]: *** [release\test.exe] Error 1

    mingw32-make: *** [release] Error 2

    The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
    Error while building project test (target: Desktop)
    When executing build step 'Make'
    //================================================== ==========
    thank you.
    Last edited by high_flyer; 5th May 2011 at 10:01. Reason: code tags

  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: How i can access my custom plugin when i loaded a ui file, my program crashed

    do you read the responses you get here at all?
    ==========================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

    Unhappy Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    Yes i read, i cant understand what can i do?

  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: How i can access my custom plugin when i loaded a ui file, my program crashed

    What didn't you understand from what I wrote in my last 3 posts?
    what can i do?
    Ask for clarification, don't just ignore.

    Do you understand what using code tags means?
    ==========================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
    11
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanked 1 Time in 1 Post

    Default Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    Quote Originally Posted by serjik View Post
    release/main.o:main.cpp.text+0x304): undefined reference to `_imp___ZN7QGLabel16staticMetaObjectE'
    I think the compiler finds the declaration of QGLabel, but the linker can't find the sourcecode of QGLabel, because it does not exists in your prog. But it is logic...

    First, you have to create your lib - for example "qglabel". Here you have to export (Q_DECL_EXPORT) your class QGLabel. Perhaps use the template fo QtCreator. This lib you have to use in your QGLabelPlugin.
    Use in your *.pro-File of your QGLabelPlugin (I think because of mingw32 different notation in LIBS...):
    Qt Code:
    1. # where your lib is stored
    2. LIBS += -L"c:/TEST/bin" -lqglabel
    3. # where the header is stored
    4. INCLUDEPATH *= C:/TEST/src
    To copy to clipboard, switch view to plain text mode 
    This lib you have to use in your Main-Prog, too, beacuse you want to use the class QGLabel.
    Use in your *.pro-File of your Main-Prog:
    Qt Code:
    1. # where your lib is stored
    2. LIBS += -L"c:/TEST/bin" -lqglabel
    3. # where the header is stored
    4. INCLUDEPATH *= C:/TEST/src
    To copy to clipboard, switch view to plain text mode 

    The QUiLoader needs the Plugins of the QtDesigner, too. Because of this, you have to say the QUiLoader where your Plugin is stored.
    I hope I could help a little bit.

    ---------------------------------------------------------------------------------------------------------
    EDIT
    But the implementation is in the plugin, which is loaded.
    That's right. @serjik: Sorry for confusing.
    Last edited by SamFredericks; 5th May 2011 at 13:11.

  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: How i can access my custom plugin when i loaded a ui file, my program crashed

    I think the compiler finds the declaration of QGLabel, but the linker can't find the sourcecode of QGLabel, because it does not exists in your prog.
    But the implementation is in the plugin, which is loaded.
    In such a case it should be enough if he has the header for the signatures, the address of the object is loaded via the plugin, if it was not, he could not have seen an instance of his custom widget in the GUI. (which is my understanding that he does)
    The instance of his custom widget is in the gui, his problem is (if I understood correctly) is that he is unable to get the instance of it.
    Even if he wouldn't be able to call functions on his custom widget pointer (which i think he should in this case) he should be able to receive valid address at least.
    ==========================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

    Smile Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    Hello guys,
    high_flyer: What didn't you understand from what I wrote in my last 3 posts?
    OK 1)QStringList strlPaths = loader.pluginPaths (); its shoes QUiLoader available plugins paths in a QStringList .
    2)QList<QGLabel*> lstLabels = ui->findChildren<QGLabel*>();
    generate a QList with QGLabel class type and fill lstLabels with ui's QGLabel type CHILDREN, this is i exactly need, i need to access my ui widgets(custom plugins)

    ---------------------------------------------------------------------------

    SamFredericks thank you for reply, i try your idea....


    ---------------------------------------------------------------------------
    I love you Qt BUT why you have not any sample for my problem ;()

  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: How i can access my custom plugin when i loaded a ui file, my program crashed

    generate a QList with QGLabel class type and fill lstLabels with ui's QGLabel type CHILDREN, this is i exactly need, i need to access my ui widgets(custom plugins)
    Well, do you get an empty list or not?
    ==========================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: How i can access my custom plugin when i loaded a ui file, my program crashed

    Hello high_flyer, sorry for my late,
    Well, do you get an empty list or not?
    yes i get an empty list, any idea?

  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: How i can access my custom plugin when i loaded a ui file, my program crashed

    well, either what you are reporting is incorrect, or something else is wrong.
    If the list you get is empty, it means there are no QGLabel objects in your ui - but you claim you see them.
    So I don't know what to tell you.
    ==========================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. #11
    Join Date
    May 2011
    Posts
    21
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows
    Thanks
    2

    Default Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    Dear Sir, i design a ui file with QtDesigner and i use for example Qt's standard widget same as QLabel, after loading this ui file by UiLoader, i can make a QList and accsess all this widgets, but problem is in custom widgets , when i use them and after loading ui file by UiLoader, i can see loaded custom widgets but when i try to access them by using QList<QGLabel*> lstLabels = ui->findChildren<QGLabel*>(); the list is empty,
    is it possible a LIB error? or can u show a sample? PLEASE...

  12. #12
    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: How i can access my custom plugin when i loaded a ui file, my program crashed

    As I said, I can't explain the behavior your are experiencing.
    Maybe someone else can help you further.

    Good luck!
    ==========================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.

  13. #13
    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: How i can access my custom plugin when i loaded a ui file, my program crashed

    Are your QGLabels children of the form widget, or are they children of another widget on the forum?
    If the later, you will have first to extract the parent of your QGLabels, and call findChildren() on that 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.

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

    Smile Re: How i can access my custom plugin when i loaded a ui file, my program crashed

    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.

  15. #15
    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: How i can access my custom plugin when i loaded a ui file, my program crashed

    Would be nice if you explain what the problem was - and how you solved it - for other users that might have a similar problem.
    ==========================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: 7
    Last Post: 11th April 2013, 10:55
  2. Replies: 1
    Last Post: 4th March 2011, 10:46
  3. Replies: 2
    Last Post: 9th December 2010, 14:11
  4. Replies: 3
    Last Post: 2nd December 2010, 22:44
  5. Gif plugin loaded but QImage cant read gif file.
    By spsingh in forum Installation and Deployment
    Replies: 0
    Last Post: 30th July 2010, 13:26

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.