Dear Sir!
The following error occurs when I make the project.
mywidget.
o: In function `MyWidget
::MyWidget(QWidget*)':mywidget.cpp:(.text+0x48): undefined reference to `QUiLoader::QUiLoader(QObject*)'
mywidget.cpp:(.text+0x119): undefined reference to `QUiLoader::~QUiLoader()'
mywidget.o: In function `MyWidget::MyWidget(QWidget*)':
mywidget.cpp:(.text+0x235): undefined reference to `QUiLoader::load(QIODevice*, QWidget*)'
mywidget.cpp:(.text+0x2d3): undefined reference to `QUiLoader::~QUiLoader()'
collect2: ld returned 1 exit status
mywidget.o: In function `MyWidget::MyWidget(QWidget*)':
mywidget.cpp:(.text+0x48): undefined reference to `QUiLoader::QUiLoader(QObject*)'
mywidget.cpp:(.text+0xb5): undefined reference to `QUiLoader::load(QIODevice*, QWidget*)'
mywidget.cpp:(.text+0x119): undefined reference to `QUiLoader::~QUiLoader()'
mywidget.cpp:(.text+0x153): undefined reference to `QUiLoader::~QUiLoader()'
mywidget.o: In function `MyWidget::MyWidget(QWidget*)':
mywidget.cpp:(.text+0x1c8): undefined reference to `QUiLoader::QUiLoader(QObject*)'
mywidget.cpp:(.text+0x235): undefined reference to `QUiLoader::load(QIODevice*, QWidget*)'
mywidget.cpp:(.text+0x299): undefined reference to `QUiLoader::~QUiLoader()'
mywidget.cpp:(.text+0x2d3): undefined reference to `QUiLoader::~QUiLoader()'
collect2: ld returned 1 exit status
To copy to clipboard, switch view to plain text mode
//mywidget.h code is as follows
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QtGui>
{
Q_OBJECT
public:
};
#endif //MYWIDGET_H
#ifndef MYWIDGET_H
#define MYWIDGET_H
#include <QtGui>
class MyWidget: public QDialog
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
};
#endif //MYWIDGET_H
To copy to clipboard, switch view to plain text mode
//mywidget.cpp code as follows;
#include "mywidget.h"
#include <QtUiTools/QUiLoader>
#include <QFile>
MyWidget
::MyWidget(QWidget *parent
){
QFile file("dlgtextscroller.ui");
file.
open(QFile::ReadOnly);
QWidget *myWidget
= loader.
load(&file,
this);
file.close();
layout->addWidget(myWidget);
setLayout(layout);
}
#include "mywidget.h"
#include <QtUiTools/QUiLoader>
#include <QFile>
MyWidget::MyWidget(QWidget *parent)
: QDialog(parent)
{
QUiLoader loader;
QFile file("dlgtextscroller.ui");
file.open(QFile::ReadOnly);
QWidget *myWidget = loader.load(&file, this);
file.close();
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(myWidget);
setLayout(layout);
}
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?
Bookmarks