Results 1 to 20 of 22

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

Threaded 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

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

    Hello
    I design a simple Qt designer custom plugin, i need this plugin for Qt Designer, its ok and it has no problem, i start to design my main program, i want to load a ui file which contains my custom widgets, i use uitools to load this ui file and also with no problem,
    but i need to access this custom widgets in ui file after loading, here is a small problem and it's just not work. i attached my custom plugin source and two test projects, what can i do ? any suggestion ? PLEASE!?!

    Qt Code:
    1. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    2. main.cpp===========
    3.  
    4. #include <QApplication>
    5. #include <QUiLoader>
    6. #include <QWidget>
    7. #include <QFile>
    8. #include <QMainWindow>
    9. #include <QtGui>
    10.  
    11. #include "QGLabel.h"//???????????????????
    12.  
    13. //Qt 4.7.0
    14.  
    15. int main(int argc, char **argv)
    16. {
    17. Q_INIT_RESOURCE(test);
    18.  
    19. QApplication app(argc, argv);
    20.  
    21. QUiLoader loader;
    22. QFile uiFile(":/test.ui");
    23. uiFile.open(QIODevice::ReadOnly);
    24. QWidget *ui = loader.load(&uiFile);
    25. uiFile.close();
    26.  
    27. ui->show();
    28.  
    29. //-------------------------------------------------------------------------
    30.  
    31. //after loading this form i need to access its child widgets
    32. // QGLabel *l1 = qFindChild<QGLabel *>(ui, "g0");
    33.  
    34. qDebug() << "---------------------";
    35. // qDebug() << l1;//here shoes the pointer is null
    36. qDebug() << "---------------------";
    37.  
    38. //but when i try to access one of this child custom widgets
    39. //my program crashed
    40. // l1->setText("i can change it");//here crashed
    41.  
    42. //so i need to make a QList of this custom widgets
    43. //QList<QGLabel *> allQGLabels = ui->findChildren<QGLabel *>();
    44.  
    45. //PLEASE what can i do??
    46.  
    47. return app.exec();
    48. }
    To copy to clipboard, switch view to plain text mode 
    //++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
    test.prj ===========


    CONFIG += uitools



    RESOURCES += test.qrc

    SOURCES += main.cpp

    #HEADERS += QGLabel.h


    //++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++
    Attached Files Attached Files
    Last edited by high_flyer; 4th May 2011 at 08:58. Reason: code tags

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.