convert qml project to qtwidgets
This commit is contained in:
+31
-21
@@ -4,38 +4,48 @@ project(llink VERSION 0.1 LANGUAGES CXX)
|
|||||||
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Quick)
|
find_package(Qt6 REQUIRED COMPONENTS
|
||||||
|
Core
|
||||||
|
Gui
|
||||||
|
Widgets
|
||||||
|
)
|
||||||
|
|
||||||
qt_standard_project_setup(REQUIRES 6.8)
|
qt_standard_project_setup(REQUIRES 6.8)
|
||||||
|
|
||||||
qt_add_executable(appllink
|
qt_add_executable(llink
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
src/MainWindow.cpp
|
||||||
|
src/MainWindow.h
|
||||||
qt_add_qml_module(appllink
|
|
||||||
URI llink
|
|
||||||
QML_FILES
|
|
||||||
Main.qml
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
|
||||||
# If you are developing for iOS or macOS you should consider setting an
|
# If you are developing for iOS or macOS you should consider setting an
|
||||||
# explicit, fixed bundle identifier manually though.
|
# explicit, fixed bundle identifier manually though.
|
||||||
set_target_properties(appllink PROPERTIES
|
set_target_properties(llink PROPERTIES
|
||||||
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appllink
|
# MACOSX_BUNDLE_GUI_IDENTIFIER com.example.llink
|
||||||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
|
||||||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
|
||||||
MACOSX_BUNDLE TRUE
|
MACOSX_BUNDLE TRUE
|
||||||
WIN32_EXECUTABLE TRUE
|
WIN32_EXECUTABLE TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(appllink
|
target_link_libraries(llink
|
||||||
PRIVATE Qt6::Quick
|
PRIVATE
|
||||||
|
Qt6::Core
|
||||||
|
Qt6::Gui
|
||||||
|
Qt6::Widgets
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS appllink
|
install(TARGETS llink
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
qt_generate_deploy_app_script(
|
||||||
|
TARGET llink
|
||||||
|
OUTPUT_SCRIPT deploy_script
|
||||||
|
NO_UNSUPPORTED_PLATFORM_ERROR
|
||||||
|
)
|
||||||
|
install(SCRIPT ${deploy_script})
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import QtQuick
|
|
||||||
|
|
||||||
Window {
|
|
||||||
width: 640
|
|
||||||
height: 480
|
|
||||||
visible: true
|
|
||||||
title: qsTr("Hello World")
|
|
||||||
}
|
|
||||||
+6
-15
@@ -1,20 +1,11 @@
|
|||||||
#include <QGuiApplication>
|
#include <QApplication>
|
||||||
#include <QQmlApplicationEngine>
|
#include "src/MainWindow.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
qDebug() << "Hello test";
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
QGuiApplication app(argc, argv);
|
MainWindow w;
|
||||||
|
w.show();
|
||||||
QQmlApplicationEngine engine;
|
return a.exec();
|
||||||
QObject::connect(
|
|
||||||
&engine,
|
|
||||||
&QQmlApplicationEngine::objectCreationFailed,
|
|
||||||
&app,
|
|
||||||
[]() { QCoreApplication::exit(-1); },
|
|
||||||
Qt::QueuedConnection);
|
|
||||||
engine.loadFromModule("llink", "Main");
|
|
||||||
|
|
||||||
return app.exec();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
//
|
||||||
|
// Created by arjun-flowylabs on 1/10/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
||||||
|
{
|
||||||
|
QWidget *centralWidget = new QWidget(this);
|
||||||
|
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
||||||
|
QPushButton *button = new QPushButton("Clickable Button", centralWidget);
|
||||||
|
|
||||||
|
layout->addWidget(button);
|
||||||
|
layout->setAlignment(button, Qt::AlignCenter);
|
||||||
|
setCentralWidget(centralWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QMainWindow::resizeEvent(event); // Let layout finish first
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Created by arjun-flowylabs on 1/10/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef LLINK_MAINWINDOW_H
|
||||||
|
#define LLINK_MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
class MainWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //LLINK_MAINWINDOW_H
|
||||||
Reference in New Issue
Block a user