i'm completely new to Qt but i managed to get some simple windows and frames to work. I'm running Eclipse on a 64 bit Kubuntu system. After editing my code in Eclipse, im running qmake and make from command line.
Yesterday i gave a try to Qt Designer, which works fine for me, compared to "hard-code" the widgets and buttons in eclipse. However, i won't switch to QT Creator because i'm very used to Eclipse.
My goal is to create the GUI in Qt Designer and use the generated code in Eclipse.
Running qmake -project, qmake and make generates a header file for my Mainwindow, containing the class code.
But when i try to include this header file in my Eclipse code, make stops with an error because g++ can't find the header file (seems the header has not been created yet).
I have to admit, im still confused about the Qt building process. So, how could i manage to design my GUI via Qt Designer and still use Eclipse as my coding IDE?
Greetings, lugge
Edit: My Eclipse Project is a "Empty Makefile Project". As far as i know, this means i have to take care of the whole build process. Eclipse wont do anything for me.
I have not tried running "make" from Eclipse because the Makefile has to be generated by qmake. Thus, after eiting and saving my code in Eclipse i run qmake and make from command line.
Qmake senses there is a .ui file and generates the header file for this class. Problem is if i try to include this header in Eclipse, my source code file can't be compiled.
For me it seems thats when "make" invokes g++ with my source code file, the header of the GUI has not been created.
So why am I doing it this way? Well, I don't want to be addicted to a IDE like Qt Creator or stuff. Because that means, everony trying to compile my project needs meta-informations such as a config-file or project-specific settings for that specific IDE.
In my C-projects i use a handwritten Makefile, so you just need to have GCC installed (which you usually have) and type "make".
I'm trying to get as close as possible to this with Qt-projects.
You need 4 things :
=> about.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>A Propos</string>
</property>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
An about Window (about.cpp) =>
#include "about.h"
#include "ui_about.h"
About::About(QWidget *parent) : QDialog(parent), ui(new Ui::About)
{
ui->setupUi(this);
}
About::~About()
{
delete ui;
}
(about.h) =>
#ifndef ABOUT_H
#define ABOUT_H
#include <QDialog>
namespace Ui {
class About;
}
class About : public QDialog
{
Q_OBJECT
public:
explicit About(QWidget *parent = 0);
~About();
private:
Ui::About *ui;
};
#endif // ABOUT_H
In the .pro file
SOURCES += about.cpp
HEADERS += about.h
FORMS += about.ui
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.