Last active
June 28, 2024 14:03
-
-
Save traversaro/2f68aaa76f35f83b509183049eec864c to your computer and use it in GitHub Desktop.
Simple qt6/qt5 program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.16) | |
# Set the project name and version | |
project(HelloWorld VERSION 1.0 LANGUAGES CXX) | |
# Find the Qt package | |
option(USE_QT6 "ON for Qt6, OFF for Qt5" ON) | |
if(USE_QT6) | |
find_package(Qt6 REQUIRED COMPONENTS Widgets) | |
else() | |
find_package(Qt5 REQUIRED COMPONENTS Widgets) | |
endif() | |
# Add the main.cpp file to the project | |
add_executable(HelloWorld main.cpp) | |
# Link the Qt6 Widgets library to the project | |
target_link_libraries(HelloWorld PRIVATE Qt::Widgets) | |
add_executable(printprefixpath printprefixpath.cpp) | |
target_link_libraries(printprefixpath PRIVATE Qt::Widgets) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QApplication> | |
#include <QPushButton> | |
int main(int argc, char *argv[]) { | |
QApplication app(argc, argv); | |
QPushButton hello("Hello World"); | |
hello.resize(100, 30); | |
hello.show(); | |
return app.exec(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QCoreApplication> | |
#include <QLibraryInfo> | |
#include <QDebug> | |
int main(int argc, char *argv[]) | |
{ | |
QString prefixPath = QLibraryInfo::location(QLibraryInfo::PrefixPath); | |
qDebug() << "PrefixPath:" << prefixPath; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment