Results 1 to 8 of 8

Thread: undefined reference to `QUiLoader::QUiLoader(QObject*)'

  1. #1
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Exclamation undefined reference to `QUiLoader::QUiLoader(QObject*)'

    Dear Sir!
    The following error occurs when I make the project.

    Qt Code:
    1. mywidget.o: In function `MyWidget::MyWidget(QWidget*)':
    2. mywidget.cpp:(.text+0x48): undefined reference to `QUiLoader::QUiLoader(QObject*)'
    3. mywidget.cpp:(.text+0xb5): undefined reference to `QUiLoader::load(QIODevice*, QWidget*)'
    4. mywidget.cpp:(.text+0x119): undefined reference to `QUiLoader::~QUiLoader()'
    5. mywidget.cpp:(.text+0x153): undefined reference to `QUiLoader::~QUiLoader()'
    6. mywidget.o: In function `MyWidget::MyWidget(QWidget*)':
    7. mywidget.cpp:(.text+0x1c8): undefined reference to `QUiLoader::QUiLoader(QObject*)'
    8. mywidget.cpp:(.text+0x235): undefined reference to `QUiLoader::load(QIODevice*, QWidget*)'
    9. mywidget.cpp:(.text+0x299): undefined reference to `QUiLoader::~QUiLoader()'
    10. mywidget.cpp:(.text+0x2d3): undefined reference to `QUiLoader::~QUiLoader()'
    11. collect2: ld returned 1 exit status
    To copy to clipboard, switch view to plain text mode 

    //mywidget.h code is as follows
    Qt Code:
    1. #ifndef MYWIDGET_H
    2. #define MYWIDGET_H
    3. #include <QtGui>
    4.  
    5. class MyWidget: public QDialog
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. MyWidget(QWidget *parent = 0);
    11.  
    12. };
    13. #endif //MYWIDGET_H
    To copy to clipboard, switch view to plain text mode 

    //mywidget.cpp code as follows;

    Qt Code:
    1. #include "mywidget.h"
    2. #include <QtUiTools/QUiLoader>
    3. #include <QFile>
    4. MyWidget::MyWidget(QWidget *parent)
    5. : QDialog(parent)
    6. {
    7. QUiLoader loader;
    8. QFile file("dlgtextscroller.ui");
    9. file.open(QFile::ReadOnly);
    10. QWidget *myWidget = loader.load(&file, this);
    11. file.close();
    12.  
    13. QVBoxLayout *layout = new QVBoxLayout;
    14. layout->addWidget(myWidget);
    15. setLayout(layout);
    16. }
    To copy to clipboard, switch view to plain text mode 

    //main.cpp code
    #include <QApplication>
    #include "mywidget.h"

    int main(int argc, char **argv)
    {
    QApplication app(argc,argv);
    MyWidget *dialog=new MyWidget;
    dialog->show();

    return app.exec();
    }

    What is wrong in this?
    Attached Files Attached Files
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    You forgot to include UiLoader in mywidget.cpp.
    Add:
    Qt Code:
    1. #include <QUiLoader>
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    QUiLoader is part of QtUiTools module.
    CONFIG += uitools
    J-P Nurmi

  4. The following 2 users say thank you to jpn for this useful post:

    ashukla (18th December 2007), marcel (18th December 2007)

  5. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    Quote Originally Posted by jpn View Post
    QUiLoader is part of QtUiTools module.
    Oh, God damn it...
    I really should answer a post AFTER reading it for more than 10 seconds.

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    Quote Originally Posted by marcel View Post
    I really should answer a post AFTER reading it for more than 10 seconds.
    True but then somebody might answer before you We should really have some policy about it...

  7. #6
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    Quote Originally Posted by wysota View Post
    True but then somebody might answer before you We should really have some policy about it...
    Dear Sir!
    I am agree with you.
    with best regards!
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  8. #7
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    Qt Code:
    1. MyWidget::MyWidget(QWidget *parent)
    2. : QDialog(parent)
    3. {
    4. QUiLoader loader;
    5. QFile file("dlgtextscroller.ui");
    6. file.open(QFile::ReadOnly);
    7. QWidget *myWidget = loader.load(&file, 0);
    8. file.close();
    9.  
    10. QVBoxLayout *layout = new QVBoxLayout;
    11. layout->addWidget(myWidget);
    12. setLayout(layout);
    13. //myWidget->resize(800,600);
    14. }
    To copy to clipboard, switch view to plain text mode 
    My .ui is loaded but displays in a small rectangle size,then I resize it manually for viewing.
    I resize it with above code but there is no effect what I do for that.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

  9. #8
    Join Date
    Oct 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: undefined reference to `QUiLoader::QUiLoader(QObject*)'

    sorry.... I haven`t get it what de solution is?? I have the same problem...
    I put #include <QtUiTools/QUiLoader>
    beacues <QUiLoader> is not correct it says :S please some help

Similar Threads

  1. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 18:33
  2. MS Sql native driver??
    By LordQt in forum Qt Programming
    Replies: 4
    Last Post: 9th October 2007, 14:41
  3. error undefined reference ...............
    By amit_pansuria in forum Qt Programming
    Replies: 2
    Last Post: 8th June 2007, 15:28
  4. how to correctly compile threads support?
    By srhlefty in forum Installation and Deployment
    Replies: 9
    Last Post: 25th June 2006, 20:15
  5. Strange error while using Q3Canvas
    By Kapil in forum Newbie
    Replies: 13
    Last Post: 15th June 2006, 20:36

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.