PDA

View Full Version : Good looking app wihout QtQuick?



Icamer
21st April 2016, 18:58
Hi.
I have to make an application that would use C++ and QSerialPort (smart house system) and look minimalistic and user-friendly (like QtQuick apps).
Should I go for the QtQuick and (somehow???) connect it to the QWidget classes (or backwards - QtQuick UI to QWidget project) or is there a good way to make an phone-like app with QtWidget?
Thank You in advance.

anda_skoa
21st April 2016, 19:15
If you want a phone like app, then you definitely want to go with QtQuick.

Any reason you can't use it?

Cheers,
_

Icamer
17th May 2016, 23:39
Well I am new to Qt and especially QtQuick, so I don't know how to, f.e. make a MouseArea that will onclicked send signal to main.cpp to use a function that will return a number between 0 and 5, then print the number into a QtQuick Text field. I am trying to do something with QQmlProperty. I have smth like



QApplication app(argc, argv);
QQmlApplicationEngine engine2;
QQmlEngine engine;
QQmlComponent component(&engine,QUrl::fromLocalFile("/home/smth/main.qml"));
QObject *object = component.create();
QObject *rect = object->findChild<QObject*>("applicationWindow1");
}


How do I add smth like


rect->setProperty("visibility", "FullScreen");
to applicationWindow1

or change a Text field in smth like.

name->setProperty("thisisthename")

Or in any other way i need to make a connection between QML and .cpp files.

anda_skoa
18th May 2016, 06:20
That's way to complicated.

Just use the QQmlApplicationEngine with a Window in the QML file or a QQuickWindow.

In either case prepare a QObject derived class as the interface that your C++ offers to QML.
Create an object of that class before loading the QML into the engine/view and set it via the root context's setContextPropery() method.

Any slot or Q_INVOKABLE marked method on that object can then be called from QML.

Cheers,
_