qt-chat-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit caf2d34280254455ab5dde758e5047f899a47a98
Author: Silas Brack <silasbrack@gmail.com>
Date:   Fri, 26 Dec 2025 12:10:59 +0100

First commit

Diffstat:
A.gitignore | 2++
ACMakeLists.txt | 34++++++++++++++++++++++++++++++++++
Aderivation_demo.nix | 17+++++++++++++++++
Aflake.lock | 25+++++++++++++++++++++++++
Aflake.nix | 11+++++++++++
Amain.cpp | 13+++++++++++++
Amain.qml | 11+++++++++++
Aqml.qrc | 5+++++
8 files changed, 118 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +result + diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.1.0) + +project(demo VERSION 1.0.0 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) + +if(CMAKE_VERSION VERSION_LESS "3.7.0") + set(CMAKE_INCLUDE_CURRENT_DIR ON) +endif() + +# Add here any library you need +find_package(Qt5 COMPONENTS Widgets Qml Quick REQUIRED) + +# Add the resource file as it *must* be compiled (also possible with +# qmake or manually with rcc) +# https://doc.qt.io/qt-5/resources.html +# https://doc.qt.io/qt-5/qtcore-cmake-qt5-add-resources.html +set(SOURCES main.cpp) # A variable is needed as I guess it will add more sources inside +qt5_add_resources(SOURCES qml.qrc) + +add_executable(demo + ${SOURCES} +) + +# Add here any library you need +target_link_libraries(demo Qt5::Widgets Qt5::Qml Qt5::Quick) + +# Install the binary +install(TARGETS demo DESTINATION bin) diff --git a/derivation_demo.nix b/derivation_demo.nix @@ -0,0 +1,17 @@ +{ lib +, stdenv +, cmake +, qt5 +, wrapQtAppsHook +}: +stdenv.mkDerivation rec { + pname = ""; + version = ""; + + src = ./.; + nativeBuildInputs = [ cmake wrapQtAppsHook ]; + buildInputs = [ + qt5.qtbase + qt5.qtdeclarative + ]; +} diff --git a/flake.lock b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1668650906, + "narHash": "sha256-JuiYfDO23O8oxUUOmhQflmOoJovyC5G4RjcYQMQjrRE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3a86856a13c88c8c64ea32082a851fefc79aa700", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix @@ -0,0 +1,11 @@ +{ + description = "A very basic flake"; + + outputs = { self, nixpkgs }: let + pkgs = nixpkgs.legacyPackages.x86_64-darwin; + in { + + packages.x86_64-darwin.default = pkgs.libsForQt5.callPackage ./derivation_demo.nix {}; + + }; +} diff --git a/main.cpp b/main.cpp @@ -0,0 +1,13 @@ +//https://riptutorial.com/qml/example/14475/creating-a-qtquick-window-from-cplusplus +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); + + return app.exec(); +} diff --git a/main.qml b/main.qml @@ -0,0 +1,11 @@ +import QtQuick 2.5 +import QtQuick.Window 2.2 + +Window { // Must be this type to be loaded by QQmlApplicationEngine. + visible: true + title: qsTr("Hello World") + Text { + text: qsTr("Hello World") + anchors.centerIn: parent + } +} diff --git a/qml.qrc b/qml.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC>