Skip to content

Instantly share code, notes, and snippets.

@gongzhitaao
Created October 7, 2013 04:23
Show Gist options
  • Save gongzhitaao/6862501 to your computer and use it in GitHub Desktop.
Save gongzhitaao/6862501 to your computer and use it in GitHub Desktop.
A Minimum Working Example Using CMake to build project with Qt5 forms
# suppose you have created a ui file called configwin.ui
cmake_minimum_required (VERSION 2.6)
project(tst)
find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
QT5_WRAP_CPP(tst_hdr_moc configwin.h)
QT5_WRAP_UI(tst_form_hdr configwin.ui)
add_library(configwin ${tst_hdr_moc} ${tst_form_hdr})
qt5_use_modules(configwin Widgets)
add_executable(tst setting.cpp configwin)
qt5_use_modules(tst Core Gui Widgets)
#include "configwin.h"
ConfigWin::ConfigWin(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfigWin)
{
ui->setupUi(this);
}
ConfigWin::~ConfigWin()
{
delete ui;
}
#ifndef CONFIGWIN_H
#define CONFIGWIN_H
#include "ui_configwin.h"
namespace Ui {
class ConfigWin;
}
class ConfigWin : public QDialog
{
Q_OBJECT
public:
explicit ConfigWin(QWidget *parent = 0);
~ConfigWin();
private:
Ui::ConfigWin *ui;
};
#endif // CONFIGWIN_H
#include <QApplication>
#include "configwin.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ConfigWin w;
w.show();
return a.exec();
}
@bdebel
Copy link

bdebel commented Dec 16, 2016

seems to configwin.ui missing

@ANDR-ASCII
Copy link

Thank you very much!

@ivanstepanovftw
Copy link

ivanstepanovftw commented Feb 17, 2018

ui_configwin.h MISSING r u kidding???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment