Here is the code that doesn't work:
main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
MainWindow *MainForm = new MainWindow;
MainForm->show();
return app.exec();
}
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow *MainForm = new MainWindow;
MainForm->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "mainwindow_ui.h"
{
Q_OBJECT
public:
private:
Ui::MainWindow ui;
};
#endif
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "mainwindow_ui.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget * parent = 0);
private:
Ui::MainWindow ui;
};
#endif
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include <QtGui>
#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
ui.setupUi(this);
}
#include <QtGui>
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent, 0)
{
ui.setupUi(this);
}
To copy to clipboard, switch view to plain text mode
mainwindow.ui
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>248</height>
</rect>
</property>
<property name="windowTitle" >
<string>Test QT DevCPP</string>
</property>
<widget class="QWidget" name="centralWidget" />
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>248</height>
</rect>
</property>
<property name="windowTitle" >
<string>Test QT DevCPP</string>
</property>
<widget class="QWidget" name="centralWidget" />
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
To copy to clipboard, switch view to plain text mode
And here is the compile errors
Compiler: Qt
Building Makefile: "E:\slask\Qt1\Makefile.win"
Executing make clean
rm -f mainwindow.o main.o mainwindow_moc.o Project1.exe
g++.exe -c mainwindow.cpp -o mainwindow.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe -c mainwindow_moc.cpp -o mainwindow_moc.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe mainwindow.o main.o mainwindow_moc.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -L"C:/Qt/4.1.0/lib" -L"C:/QT/4.1.0/lib" -lmingw32 -lqtmain -lQtCore4 -lQtGui4
mainwindow.o(.text+0x16f):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x17b):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x25b):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x267):mainwindow.cpp: undefined reference to `vtable for MainWindow'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
Compiler: Qt
Building Makefile: "E:\slask\Qt1\Makefile.win"
Executing make clean
rm -f mainwindow.o main.o mainwindow_moc.o Project1.exe
g++.exe -c mainwindow.cpp -o mainwindow.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe -c mainwindow_moc.cpp -o mainwindow_moc.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" -I"C:/Qt/4.1.0/include" -I"C:/Qt/4.1.0/include/QtGui" -I"C:/Qt/4.1.0/include/Qt" -I"C:/Qt/4.1.0/include/QtCore" -I"C:/Qt/4.1.0/include/QtDesigner" -I"C:/Qt/4.1.0/include/QtNetwork" -I"C:/Qt/4.1.0/include/QtUiTools" -I"C:/Qt/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/mkspecs/win32-g++" -I"C:/QT/4.1.0/include" -DWIN32 -ansi -fexceptions
g++.exe mainwindow.o main.o mainwindow_moc.o -o "Project1.exe" -L"C:/Dev-Cpp/lib" -L"C:/Qt/4.1.0/lib" -L"C:/QT/4.1.0/lib" -lmingw32 -lqtmain -lQtCore4 -lQtGui4
mainwindow.o(.text+0x16f):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x17b):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x25b):mainwindow.cpp: undefined reference to `vtable for MainWindow'
mainwindow.o(.text+0x267):mainwindow.cpp: undefined reference to `vtable for MainWindow'
collect2: ld returned 1 exit status
make.exe: *** [Project1.exe] Error 1
Execution terminated
To copy to clipboard, switch view to plain text mode
I have followed these instructions
http://www.sortinonline.it/download/...T4_Dev-C++.zip
Bookmarks