This commit is contained in:
Robert 2020-11-17 17:07:02 +01:00
parent d435d6cd2b
commit 7b7910a903
5 changed files with 144 additions and 0 deletions

View file

@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.10)
project(Regression)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC_SEARCH_PATHS include/ui)
find_package(Qt5 COMPONENTS Widgets REQUIRED)
file(GLOB_RECURSE source_files
"src/*.cpp"
)
file(GLOB_RECURSE include_files
"include/*.hpp"
"include/*.ui"
)
add_executable(regression
${include_files}
${source_files}
)
target_include_directories(regression PRIVATE
include
${Qt5_INCLUDE_DIRS}
)
target_link_libraries(regression PRIVATE
Qt5::Widgets
)
if(WIN32)
add_custom_command(TARGET regression POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Widgets> $<TARGET_FILE_DIR:regression>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Gui> $<TARGET_FILE_DIR:regression>
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Qt5::Core> $<TARGET_FILE_DIR:regression>
# This is garbage, remove this, Qt just sucks
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5_DIR}/../../../plugins/platforms/qwindowsd.dll $<TARGET_FILE_DIR:regression>
COMMAND ${CMAKE_COMMAND} -E copy ${Qt5_DIR}/../../../plugins/platforms/qwindows.dll $<TARGET_FILE_DIR:regression>
)
endif()

19
include/MainWindow.hpp Normal file
View file

@ -0,0 +1,19 @@
#pragma once
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
private:
Ui::MainWindow* ui;
};

52
include/ui/MainWindow.ui Normal file
View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>146</x>
<y>102</y>
<width>271</width>
<height>91</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>28</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>

14
src/MainWindow.cpp Normal file
View file

@ -0,0 +1,14 @@
#include "MainWindow.hpp"
#include "ui_MainWindow.h"
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->label->setText("Hello, World!");
}
MainWindow::~MainWindow()
{
delete ui;
}

11
src/main.cpp Normal file
View file

@ -0,0 +1,11 @@
#include <qapplication.h>
#include "MainWindow.hpp"
int main(int argc, char** argv)
{
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}