move sources to src/; add Moc builder
This commit is contained in:
parent
ca753a42fe
commit
64e3d89818
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/app
|
|
||||||
/.rsconscache
|
/.rsconscache
|
||||||
|
/app
|
||||||
|
/build/
|
||||||
|
16
Rsconsfile
16
Rsconsfile
@ -1,5 +1,19 @@
|
|||||||
|
class Moc < Rscons::Builder
|
||||||
|
def run(target, sources, cache, env, vars)
|
||||||
|
command = %W[moc -o #{target} #{sources.first}]
|
||||||
|
standard_build("Moc #{target}", target, command, sources, env, cache)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Rscons::Environment.new do |env|
|
Rscons::Environment.new do |env|
|
||||||
sources = Dir["**/*.cc"]
|
env.add_builder(Moc.new)
|
||||||
|
sources = Dir["src/*.cc"]
|
||||||
|
env.build_dir("src", "build")
|
||||||
|
Dir["src/**/*.h"].each do |h_file|
|
||||||
|
moc_fname = env.get_build_fname(h_file, "_moc.cc")
|
||||||
|
env.Moc(moc_fname, h_file)
|
||||||
|
sources << moc_fname
|
||||||
|
end
|
||||||
env.parse_flags!("!pkg-config --cflags --libs Qt5Core Qt5Gui Qt5Widgets")
|
env.parse_flags!("!pkg-config --cflags --libs Qt5Core Qt5Gui Qt5Widgets")
|
||||||
env.parse_flags!("-fPIE")
|
env.parse_flags!("-fPIE")
|
||||||
env.Program("app", sources)
|
env.Program("app", sources)
|
||||||
|
23
main.cc
23
main.cc
@ -1,23 +0,0 @@
|
|||||||
#include <QtGui>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QtWidgets>
|
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
|
||||||
{
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
|
|
||||||
QHBoxLayout * layout = new QHBoxLayout();
|
|
||||||
|
|
||||||
QPushButton * button = new QPushButton("Press me");
|
|
||||||
layout->addWidget(button);
|
|
||||||
|
|
||||||
QLabel * label = new QLabel("Label");
|
|
||||||
layout->addWidget(label);
|
|
||||||
|
|
||||||
QWidget window;
|
|
||||||
window.setLayout(layout);
|
|
||||||
window.setWindowTitle("My Qt Application!");
|
|
||||||
window.show();
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
|
24
src/MyWindow.cc
Normal file
24
src/MyWindow.cc
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "MyWindow.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
MyWindow::MyWindow(QWidget * parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout * layout = new QHBoxLayout();
|
||||||
|
|
||||||
|
QPushButton * button = new QPushButton("Press me");
|
||||||
|
layout->addWidget(button);
|
||||||
|
|
||||||
|
QLabel * label = new QLabel("Label");
|
||||||
|
layout->addWidget(label);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
setWindowTitle("My Qt Application!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyWindow::handleButton()
|
||||||
|
{
|
||||||
|
cerr << "got a button press" << endl;
|
||||||
|
}
|
19
src/MyWindow.h
Normal file
19
src/MyWindow.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef MYWINDOW_H
|
||||||
|
#define MYWINDOW_H
|
||||||
|
|
||||||
|
#include <QtGui>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
class MyWindow : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MyWindow(QWidget * parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleButton();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
15
src/main.cc
Normal file
15
src/main.cc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <QtGui>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
#include "MyWindow.h"
|
||||||
|
|
||||||
|
int main(int argc, char * argv[])
|
||||||
|
{
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
MyWindow window;
|
||||||
|
window.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user