- "We are doomed" - 1 Update
- c++ and qt - 4 Updates
Lynn McGuire <lynnmcguire5@gmail.com>: Jan 16 04:03PM -0600 "We are doomed" https://www.carette.xyz/posts/we_are_doomed/ "The only system with a good software compatibility that I know is Windows, and this explains a ton of things keeping very old UI/UX frameworks, software and APIs to run, for example, Windows 95 compatible games like "Roller Coaster Tycoon"." "Otherwise, you are doomed." The C++ committee has screwed up and continues to screw up by not creating a graphics standard for C++. Lynn |
bubu <bruno.donati@hotmail.fr>: Jan 16 08:52PM Hi, Sorry for my bad english and sorry for my bad level in qt. I would like to use a qml program and c++ libraries (with import). I use Visual Studio on windows. I have several problems (and I put an example here-after) : - how to use c++ with qml - how to use a library written in c++ to use in a program in QML with IMPORT statement. - how to build executable and librarie with cmake? My example is here : main.qml ApplicationWindow { visible: true width: 400 height: 300 title: "Calculator" Calculatrice { id: calculatrice } Column { anchors.centerIn: parent spacing: 10 TextField { id: input1 placeholderText: "Entrez le premier nombre" validator: DoubleValidator { bottom: -1000000000.0 top: 1000000000.0 } } TextField { id: input2 placeholderText: "Entrez le deuxième nombre" validator: DoubleValidator { bottom: -1000000000.0 top: 1000000000.0 } } Row { spacing: 10 Button { text: "Additionner" onClicked: { resultLabel.text = "Résultat: " + calculator.add(parseFloat(input1.text), parseFloat(input2.text)) } } Button { text: "Soustraire" onClicked: { resultLabel.text = "Résultat: " + calculator.subtract(parseFloat(input1.text), parseFloat(input2.text)) } } Button { text: "Multiplier" onClicked: { resultLabel.text = "Résultat: " + calculator.multiply(parseFloat(input1.text), parseFloat(input2.text)) } } } Label { id: resultLabel text: "Résultat: " } } } main.cpp #include <QGuiApplication>#include <QQmlApplicationEngine>#include <QtCore>//#include "calculator.cpp"int main(int argc, char* argv[]){ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; //qmlRegisterType<Calculator>("Calculator", 1, 0, "Calculator"); const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject* obj, const QUrl& objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec();} calculator.h // calculator.h#ifndef CALCULATOR_H#define CALCULATOR_Hclass Calculator {public: double add(double a, double b) const; double subtract(double a, double b) const; double multiply(double a, double b) const;};
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment