mir ist aufgefallen das ich eine extrem hohe CPU Load auf einem Kern meines Raspberrys habe wenn ich Daten von der C++ Ebene in die QML Ebene bringe.
Ich mache das zur Zeit wie folgt:
in der main.cpp
Code: Alles auswählen
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
//Deutsche Tastatur
QEglFSFunctions deKeyboard_Layout;
deKeyboard_Layout.loadKeymap("/home/pi/Projekt/cached_UTF-8_del.qmap");
QQmlApplicationEngine engine;
Pruef_qml pruef_qml;
engine.rootContext()->setContextProperty("cppClass", &pruef_qml);
engine.rootContext()->setContextProperty("TesterDataFromCpp", QVariant::fromValue(testerData));
engine.load(QUrl(QLatin1String("qrc:/Qml/main.qml")));
return app.exec();
}
pruef_qml.cpp
Code: Alles auswählen
TesterData testerData;
void Pruef_qml::LoadProcessDataToQml(void)
{
emit sendToQml_TesterData(testerData);
}
Code: Alles auswählen
struct TesterData
{
private: //for QML
Q_GADGET
Q_PROPERTY(bool communication MEMBER communication)
...
public: //copy for CPP
bool communication;
...
}
extern TesterData testerData;
Die Varriante mit Q_GADGET ist die einzige die ich gefunden habe um Strukturen zu übertragen .
Sobald ich mein Programm starte braucht es 80% - 90% CPU Last auf meinem Kern. (RPI2 Quad Core)
Unterbinde ich das Updaten der QML Oberfläche habe ich 4% - 8% CPU Last.
Würde mich sehr über eure Anregungen freuen.
Vielen Dank im Voraus.