Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qproperty
    Log in to post

    • UNSOLVED Using custom type in Q_PROPERTY
      General and Desktop • moc qproperty meta-objects • • Venkateswaran  

      1
      0
      Votes
      1
      Posts
      39
      Views

      No one has replied

    • UNSOLVED " Error : Cannot assign [undefined] to QString " while communicating between C++ and QML
      QML and Qt Quick • qml c++ qtquick2 qproperty • • Quentin91  

      6
      0
      Votes
      6
      Posts
      1365
      Views

      @Ronak5 no, I didn't. that's probably not the problem any current test is trying to share a bool with QML and the problem is the same. but I'll remember to try it when sharing a string :) So here is a simpler project and use a Singleton. One of the problem was that I have to declare my object in the QML when using qmlRegisterType. And I don't want to. So here is the new code, the error is the same. I followed the example of the doc here https://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html miniModel.h (the singleton) #ifndef _MINIMODEL_H_ #define _MINIMODEL_H_ #include <stdlib.h> #include <stdio.h> #include <iostream> #include <string> #include <QtGui/qguiapplication.h> #include <QtQml/qqmlcontext.h> #include <QtQml/qqmlapplicationengine.h> #include <QtCore/qdebug.h> #include <QtCore/qobject.h> #include <QtCore/qvariant.h> class MiniModel : public QObject { Q_OBJECT Q_PROPERTY(bool miniboule READ miniboule WRITE setMiniboule NOTIFY minibouleChanged) public: MiniModel(); bool miniboule(); void setMiniboule(bool bouboule); signals: void minibouleChanged(); private: bool m_miniboule; }; #endif main.cpp v1 : singleton using a QObject #include "miniModel.h" //defining a miniModel instance as a singleton static QObject* mp_singleton(QQmlEngine* engine, QJSEngine* scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) MiniModel* miniSingleton = new MiniModel(); return miniSingleton; } int main(int argc=0, char* argv[]=nullptr) { printf("\n launching \n"); QGuiApplication app(argc, argv); qmlRegisterSingletonType<MiniModel>("myModel.miniModel", 1, 0, "MiniModel",mp_singleton); QQmlApplicationEngine engine; engine.addImportPath(QStringLiteral("..\\..\\..\\..\\Tools\\Qt\\5.12.0\\x64\\5.12.0\\msvc2017_64\\qml")); engine.load(QUrl(QStringLiteral("..\\..\\..\\miniModel.qml"))); return app.exec(); } main.cpp v2 : singletin using QJSValue #include "miniModel.h" static QJSValue m_singletonModel(QQmlEngine* engine, QJSEngine* scriptEngine) { Q_UNUSED(engine) static bool m_miniboule; QJSValue miniModel = scriptEngine->newObject(); miniModel.setProperty("miniboule", m_miniboule); return miniModel; } int main(int argc = 0, char* argv[] = nullptr) { printf("\n launching \n"); QGuiApplication app(argc, argv); qmlRegisterSingletonType("myModel.miniModel", 1, 0, "MiniModel", m_singletonModel); QQmlApplicationEngine engine; engine.addImportPath(QStringLiteral("..\\..\\..\\..\\Tools\\Qt\\5.12.0\\x64\\5.12.0\\msvc2017_64\\qml")); engine.load(QUrl(QStringLiteral("..\\..\\..\\miniModel.qml"))); return app.exec(); } and the QML. be careful, it's tough import QtQuick 2.5 import QtQuick.Window 2.5 import QtQuick.Controls 1.4 import myModel.miniModel 1.0 as MyModel ApplicationWindow { id: root width: 300 height: 480 visible:true Text{ id: textTest x: 62 y: 75 color: "#d21616" text: "vanilla" visible: false//the text is supposed to appear when clicking in the mouseArea } MouseArea{ anchors.fill: parent onClicked: textTest.visible= MyModel.Minimodel.miniboule//the boolean I want to acess, defined to true } } now, the error changed, since I called MyModel.MiniModel.miniboule instead of just MiniModel.miniboule the error is TypeError: Cannot read property 'miniboule' of undefined
    • UNSOLVED Accessing QObject class properties which is stored in QList
      QML and Qt Quick • qml qtquick qtquick2 qproperty • • pra7  

      4
      0
      Votes
      4
      Posts
      1332
      Views

      ClassB, you are using it in a property. By the way, why not use QObjectList and a Q_INVOKABLE method ? Might be more straightforward. More information on how to integrate CPP with QML here.
    • SOLVED Q_PROPERTY : problems with DESIGNABLE flag
      General and Desktop • qproperty designable • • Gianluca86  

      5
      0
      Votes
      5
      Posts
      965
      Views

      I would have preferred a quicker way using Q_PROPERTY, but I think the only way is what you've suggested to me. Thanks so much
    • UNSOLVED Setting QList properties in qss files
      General and Desktop • qlist qss qproperty • • mongrelmac  

      5
      0
      Votes
      5
      Posts
      1633
      Views

      I see. Thanks @raven-worx @SGaist!
    • UNSOLVED QPropertyAnimations too big cpu usage for hover effects
      General and Desktop • qproperty effect fade effects css3 • • 0x1337  

      1
      0
      Votes
      1
      Posts
      541
      Views

      No one has replied

    • SOLVED It is possible to have a read only Q_PROPERTY with MEMBER?
      General and Desktop • qproperty readonly • • mcleary  

      5
      0
      Votes
      5
      Posts
      4789
      Views

      @mcleary When one declares a property with MEMBER feature the QMetaProperty is reporting that the property is writable. This is quite strange indeed. I solve my problem removing the MEMBER declaration! This is certainly a possibility. Still I'm glad it's working for you,
    • UNSOLVED Changing Q_PROPERTY in pseudo state of a widget stylesheet does not notify
      General and Desktop • qproperty • • Arie  

      8
      0
      Votes
      8
      Posts
      2487
      Views

      Any other idea why the WRITE function is not called at the widget’s pseudo state change when the stylesheet has different qproperty values defined for the states?
    • [SOLVED] Q_INVOKABLE vs Q_PROPERTY (QML hanging...)
      QML and Qt Quick • qproperty qinvokable blocktypeisvali • • Erakis  

      3
      0
      Votes
      3
      Posts
      12540
      Views

      Hi, Q_INVOKABLE is used to make functions accessible throughout Qt meta object system. Q_PROPERTY is much more complex and offers additional features
    • [Solved] Compilation error when using a flagable enumeration in a Q_PROPERTY
      General and Desktop • moc qproperty qt 5.5.0 qflag • • kylek  

      6
      0
      Votes
      6
      Posts
      3072
      Views

      You don't have to mix anything. What you use in your enum are hexadecimal values not binary. That means (left side hex, right side binary): 0x0 == 0, 0x1 == 1, 0x10 == 10000, 0x100 == 100000000! I guess what you actually want is what Chris Kawa said: 0x01 == 1, 0x02 == 10, 0x04 == 100, 0x08 == 1000, 0x10 == 10000
    • [SOLVED] QPushButton and Icon -- How To Move Icon More To The Left?
      General and Desktop • qpushbutton icon qproperty styling • • maximo  

      2
      0
      Votes
      2
      Posts
      9415
      Views

      After scouring the web, it appears that the only way to do this is the very complex technique of subclassing the widget. It's easier to just put another button on it, but then I had the problem where I couldn't pass a hover event to the QPushButton underneath it. This lead me to learn the technique on StackOverflow of building an eventFilter.
    • Problems with QML Bindings
      QML and Qt Quick • qml signals qproperty qml binding • • Lixcode  

      3
      0
      Votes
      3
      Posts
      826
      Views

      Thanks! I fix the problem. All works fine, but I have a Rectangle over that hide the window background and that was the problem.
    • Q_DECLARE_INCOMPATIBLE_FLAG - this seems like a useful macro, but I can't find any documentation on it.
      General and Desktop • qobject qproperty • • shavera  

      1
      0
      Votes
      1
      Posts
      579
      Views

      No one has replied

    • Qt crashes when even i refractor ->generate missing Q_PROPERTY members
      QML and Qt Quick • qt5.4 crash qproperty • • vishnu  

      4
      0
      Votes
      4
      Posts
      1018
      Views

      @vishnu Works on Ubuntu 14.04 with Qt 5.4.1 Edit: Works on Windows 7 64 bit with Qt 5.4.1 and MSVC 2010 too. Try searching https://bugreports.qt.io for possible bugs if any.