generated from me/template-mit
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb38215c04 | ||
|
|
0bea8e4901 |
No files matched your search
+56
@@ -0,0 +1,56 @@
|
|||||||
|
# C++ objects and libs
|
||||||
|
*.slo
|
||||||
|
*.lo
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.la
|
||||||
|
*.lai
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dll
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Qt-es
|
||||||
|
object_script.*.Release
|
||||||
|
object_script.*.Debug
|
||||||
|
*_plugin_import.cpp
|
||||||
|
/.qmake.cache
|
||||||
|
/.qmake.stash
|
||||||
|
*.pro.user
|
||||||
|
*.pro.user.*
|
||||||
|
*.qbs.user
|
||||||
|
*.qbs.user.*
|
||||||
|
*.moc
|
||||||
|
moc_*.cpp
|
||||||
|
moc_*.h
|
||||||
|
qrc_*.cpp
|
||||||
|
ui_*.h
|
||||||
|
*.qmlc
|
||||||
|
*.jsc
|
||||||
|
Makefile*
|
||||||
|
*build-*
|
||||||
|
build/
|
||||||
|
*.qm
|
||||||
|
*.prl
|
||||||
|
*.qmlls.ini
|
||||||
|
|
||||||
|
# Qt unit tests
|
||||||
|
target_wrapper.*
|
||||||
|
|
||||||
|
# QtCreator
|
||||||
|
*.autosave
|
||||||
|
|
||||||
|
# QtCreator Qml
|
||||||
|
*.qmlproject.user
|
||||||
|
*.qmlproject.user.*
|
||||||
|
|
||||||
|
# QtCreator CMake
|
||||||
|
CMakeLists.txt.user*
|
||||||
|
|
||||||
|
# QtCreator 4.8< compilation database
|
||||||
|
compile_commands.json
|
||||||
|
|
||||||
|
# QtCreator local machine specific files for imported projects
|
||||||
|
*creator.user*
|
||||||
|
|
||||||
|
*_qmlcache.qrc
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.5)
|
||||||
|
|
||||||
|
project(hello-world-qt VERSION 1.0)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
find_package(Qt6 COMPONENTS Widgets REQUIRED)
|
||||||
|
|
||||||
|
add_executable(hello-world-qt main.cpp)
|
||||||
|
|
||||||
|
target_link_libraries(hello-world-qt PRIVATE Qt6::Widgets)
|
||||||
@@ -1,3 +1,24 @@
|
|||||||
# template-mit
|
# Hello World Qt
|
||||||
|
|
||||||
Template with MIT license, protected `main` branch, and available `dev` branch.
|
A simple Qt application that displays "Hello World!" in a window with a close button.
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./hello-world-qt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Dependencies
|
||||||
|
|
||||||
|
- Qt 6
|
||||||
|
- CMake
|
||||||
|
- C++17 compiler
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#include <QApplication>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
QMainWindow mainWindow;
|
||||||
|
mainWindow.setWindowTitle("Hello World Qt");
|
||||||
|
mainWindow.resize(400, 300);
|
||||||
|
|
||||||
|
// Create central widget and layout
|
||||||
|
QWidget *centralWidget = new QWidget(&mainWindow);
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
||||||
|
|
||||||
|
// Create hello world label
|
||||||
|
QLabel *helloLabel = new QLabel("Hello World!", centralWidget);
|
||||||
|
helloLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
helloLabel->setStyleSheet("font-size: 24px; font-weight: bold;");
|
||||||
|
|
||||||
|
// Create close button
|
||||||
|
QPushButton *closeButton = new QPushButton("Close", centralWidget);
|
||||||
|
closeButton->setStyleSheet("font-size: 16px; padding: 10px;");
|
||||||
|
|
||||||
|
// Connect button to close action
|
||||||
|
QObject::connect(closeButton, &QPushButton::clicked, &mainWindow, &QMainWindow::close);
|
||||||
|
|
||||||
|
// Add widgets to layout
|
||||||
|
layout->addStretch();
|
||||||
|
layout->addWidget(helloLabel);
|
||||||
|
layout->addWidget(closeButton);
|
||||||
|
layout->addStretch();
|
||||||
|
|
||||||
|
// Set central widget
|
||||||
|
mainWindow.setCentralWidget(centralWidget);
|
||||||
|
|
||||||
|
// Show the window
|
||||||
|
mainWindow.show();
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user