Skip to content
QtWS25 Last Chance
  • 0 Votes
    16 Posts
    2k Views
    M
    Hi @dheerendra I think the issue was in NO_PLUGIN as were suggested by @Anumas here: https://forum.qt.io/post/802964 Seems to be working fine with static library now. I marked that message as a solution.
  • 0 Votes
    2 Posts
    441 Views
    GrecKoG
    @fromis_9 Controls usually provide a signal to indicate that a change has come from a user interaction signal, you should use this one instead of the "raw" <property>Changed signal that will fire both on backend and frontend changes. For CheckBox it is the toggled signal, for ComboBox activated, for TextField textEdited, ... So in your case it would be: CheckBox { id: qmlCheckBox checked: backend.myCheck onToggled: backend.myCheck = checked } Make sure to also not emit the notify signal in the setter if the property doesn't actually changed, generally done with an if at the start: void Backend::SetMyCheck(bool myCheck) { if (myCheck == m_myCheck) return; m_myCheck = myCheck; emit myCheckChanged(); }
  • 0 Votes
    2 Posts
    511 Views
    fcarneyF
    We just create models and use context properties. Or have the QML code request the model from another object via function or property. We generally have an application object that manages the lifetime of the smaller objects.
  • 0 Votes
    4 Posts
    802 Views
    raven-worxR
    @Tee_ normally a pro file results in a separate target (executable or library). Even if you "combine" them with a subdirs project. So your AppUi project must link against the AppLib
  • 0 Votes
    3 Posts
    999 Views
    eyllanescE
    Export watcher: int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; 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); QFileSystemWatcher watcher; watcher.addPath("data.json"); readJSON myGlobal; engine.rootContext()->setContextProperty("myGlobalObject", &myGlobal); engine.rootContext()->setContextProperty("watcher", &watcher); engine.load(url); return app.exec(); } and use Connections: Window { visible: true width: 800 height: 800 title: qsTr("Screen Display") DisplaysForm { function callCPP(text) { var dataOne = myGlobalObject.readingJson(text) dataOne = parseFloat(dataOne) return dataOne } function updateDisplay() { var value = callCPP("Engine_Spd") engSpd_txt.text = value var value1 = callCPP("Engine_Power") engPwr_txt.text = value1 } Connections{ target: watcher function onFileChanged(path){ console.log(path) updateDisplay() } } }
  • 0 Votes
    10 Posts
    958 Views
    fcarneyF
    Don't feel bad. I spent 3 weeks working on a solution that I eventually had to scrap and do a different way. I was really mad about it, but it was a learning experience. So in this case just check assumptions. I always have to remind myself of this.
  • C++ PROPERTY changed() to QML

    Solved General and Desktop property c++ qml c++ to qml change
    5
    0 Votes
    5 Posts
    2k Views
    T
    @KroMignon Thanks for the extensive explanation! Now I understand what I was doing wrong. Kind regards
  • 0 Votes
    4 Posts
    447 Views
    Crawl.WC
    I just noticed that XYSeries is a uncreatable type, its derived object's Q_INVOKABLE method invoke member method of DeclarativeXySeries class, and DeclarativeXySeries is a shadow class about XYSeries. Such as LineSeries is imported from DeclarativeLineSeries.
  • 0 Votes
    3 Posts
    1k Views
    Z
    Thanks, this works!
  • 0 Votes
    11 Posts
    3k Views
    D
    @SGaist Ok that makes sense. Thank you
  • 0 Votes
    4 Posts
    2k Views
    _
    Thanks a zillion. For the record: qtexttospeech.h already has on line 118 Q_DECLARE_METATYPE(QTextToSpeech::State) Hence, what's missing is the qRegisterMetaType part. Which I am adding in main.cpp before the QTextToSpeech module is loaded. qRegisterMetaType<QTextToSpeech::State>("State"); QTextToSpeech* speech = new QTextToSpeech; Then, in main.qml, I am catching the state changed signals and the state like this: Connections { target: speech onStateChanged: { console.log("speech.state "+ speech.state); if (speech.state == 1){ console.log("--- we are speaking! ---"); } else if (speech.state == 0){ console.log("--- speaking stopped! ---"); } } }
  • 0 Votes
    2 Posts
    1k Views
    R
    I solved it without signal using callback function directly: Item { id: myItem onClicked: { CppClass.registerFunction(myItem, "callback") } function callback() { console.log("Callback function called!") } } //C++ void CppClass::registerFunction(QObject* object, QString function) { struct CallbackInfo info; info.object = object; info.function = function; m_stack.push(info); } void CppClass::ready() { struct CallbackInfo info = m_callbackStack.pop(); QMetaObject::invokeMethod(info.object, info.function.toLatin1().constData()); }
  • 0 Votes
    9 Posts
    9k Views
    R
    Thank you very much, now it works fine :-) Here is the solution: ui->gauge_quick->setSource(QUrl(QStringLiteral("qrc:/qml/QtQuickProgressBar.qml"))); ui->gauge_quick->show(); auto rootObject = ui->gauge_quick->rootObject(); connect(this, SIGNAL(setGauge(QVariant)), rootObject, SLOT(setvalue(QVariant))); emit setGauge(15.5);
  • 0 Votes
    2 Posts
    2k Views
    S
    I create MyClass and pass 4 images to QML in main.cpp class.h #ifndef MYCLASS_H #define MYCLASS_H #include <QDebug> #include <QObject> class MyClass : public QObject { Q_OBJECT Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY pathChanged); public: explicit MyClass(QObject *parent = 0); MyClass(QString path) { m_imagePath = path; } QString imagePath(); void setImagePath(const QString & path); signals: void pathChanged(QString path); private: QString m_imagePath; }; #endif // MYCLASS_H main.cpp QApplication app(argc, argv); app.setWindowIcon(QIcon("qrc:/images/logo.ico")); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QList<QObject*> dataList; dataList.append(new MyClass("/images/images/zaglowek.png")); dataList.append(new MyClass("/images/images/pilot.png")); dataList.append(new MyClass("/images/images/uklad_jezdny.png")); dataList.append(new MyClass("/images/images/nozne_sterowanie.png")); engine.rootContext()->setContextProperty("myModel", QVariant::fromValue(dataList)); For Now MyClass has only image path, but it will also set state (checked-unchecked) and animation (enable-disable). I would like to reload this QList ( with another images, states etc. ) when button ( one of three ) is clicked ( TButton.qml ). How to do it ? Please help.
  • 0 Votes
    3 Posts
    1k Views
    S
    Thank you very much! Now it is much more clear for me.