Compare commits

...
2 Commits
Author SHA1 Message Date
me bb38215c04 Add example project. 2026-10-17 16:56:59 -07:00
me 0bea8e4901 Add a generic Qt gitignore to avoid build files. 2026-10-17 15:34:05 -07:00
4 changed files with 134 additions and 2 deletions

No files matched your search

+56
View File
@@ -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
+12
View File
@@ -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)
+23 -2
View File
@@ -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
+43
View File
@@ -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();
}