Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.5k Posts
  • This topic is deleted!

    Unsolved
    7
    0 Votes
    7 Posts
    61 Views
  • InnerShadow in Qt6

    Unsolved shadow effects qt6 qt5compat
    1
    0 Votes
    1 Posts
    265 Views
    No one has replied
  • Cannot #include<QQuickStyle>

    Solved
    7
    1 Votes
    7 Posts
    8k Views
    J
    @SGaist said in Cannot #include<QQuickStyle>: ine of the table a th yes ,it's there exactly。 thank you for resolving my problem
  • reusing a component with different arguments

    Solved
    7
    0 Votes
    7 Posts
    585 Views
    mzimmersM
    Excellent. I had to play with it a bit, but it works just fine. Thanks for the help. // ListComponent.qml Item { id: item height: 20 property string xxx Text { text: xxx } } // Main.qml ListModel { id: listModel ListElement { dataField: "1" } ListElement { dataField: "2" } ListElement { dataField: "3" } } ListView { anchors.fill: parent model: listModel QtObject { id: headerProperties property string xxx: "I want this for my header string." } header: ListComponent { xxx: headerProperties.xxx } delegate: ListComponent { xxx: dataField } }
  • App crash: corrupted size vs. prev_size in fastbins

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    SGaistS
    Since you are using 6.7, that should be the default yes. You can check that by setting the QT_DEBUG_PLUGINS environment variable to 1 in the terminal where you start your application.
  • How to restrict object access to files in qrc and public slot functions in C++ ?

    Unsolved
    4
    0 Votes
    4 Posts
    307 Views
    jeremy_kJ
    Off hand, no. Anything that the application's trusted QML code can reach will also be reachable for the created object. QML's local file access is less flexible than what C++ Qt and the standard library provide. I would not expect it to hinder malicious code.
  • QQmlOpenMetaObject breaks polymorphism

    Unsolved
    1
    0 Votes
    1 Posts
    138 Views
    No one has replied
  • What's the best practice to use third-party libraries in c++ sources of qt6 qml module?

    Unsolved
    1
    0 Votes
    1 Posts
    171 Views
    No one has replied
  • How to make a "focus chain" of components when they are generated with a Repeater?

    Unsolved
    5
    0 Votes
    5 Posts
    756 Views
    T
    @KH-219Design Thanks for the links, I think I'll find what I need there. I'll try to implement all this and come back here to set the post as answered if I manage!
  • How to limit touch area that will cause drawer to extend / retract ?

    Unsolved
    1
    0 Votes
    1 Posts
    125 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    5
    0 Votes
    5 Posts
    78 Views
  • Cannot call C++ method when object is created in another QML module

    Solved
    6
    0 Votes
    6 Posts
    582 Views
    K
    Ok. I finally manged singletons in QML and C++ in Qt 6.7 which could be a bit frustrating for newbies like me especialy when you are reading official Qt documentation which is reffering to another doc and another doc and you finally end with 25 pages opened in your browser. I'm writting it here in case if someone got there via google search or something. Important thing about singletons that you don't call them by id property (id doesn't matter if you set it) but class name and it must start from upper letter QML singleton global object So. If you want to have global QML object like DataModule.qml which is created just like that and have access to it from anywhere: Create your DataModule.qml file (first upper character is important). For example: pragma Singleton import QtQuick QtObject { property string someString: "foo bar" } Notice: pragma Singleton, it is important 2. In CMakeLists.txt add this: set_source_files_properties(DataModule.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) qt_add_qml_module(appMyApp URI MyApp VERSION 1.0 QML_FILES QML_FILES DataModule.qml ....... ) Notice: Make sure that set_source_files_properties is called before qt_add_qml_module. Also, not sure if it matter, but add QML_FILES DataModule.qml as first or at least before your Main.qml 3. Now you can call your someString property from anywhere without declaring class in ApplicationWindow {}. For example, just reffer to class DataModule directly: ApplicationWindow { id: mainWindow width: 640 height: 480 visible: true Component.onCompleted: { console.log(DataModule.someString); } } QObject/C++ singleton global object If you want to have global QObject/C++ access from anywhere in your QML without rootContext()->setContextProperty Create your QObject class and save it and add to project for example class MyCppInterface : public QObject { Q_OBJECT QML_ELEMENT <--- important QML_SINGLETON <--- important public: explicit MyCppInterface(QObject *parent = nullptr); Q_INVOKABLE void log(QString s) const; signals: }; Notice: You have to add both, QML_ELEMENT and QML_SINGLETON 2. Now, you DON'T NEED to declare class in ApplicationWindow to have acces to it by id like you normally did in simple QML_ELEMENT: ApplicationWindow { id: mainWindow width: 640 height: 480 visible: true MyCppInterface { id: myCppIntf } Component.onCompleted: { myCppIntf.log('something'); } } Instead. Just call it directly by class (first character is upper!) ApplicationWindow { id: mainWindow width: 640 height: 480 visible: true Component.onCompleted: { MyCppInterface.log('something'); } } Mixing both together Now. When we know how bot things work, we can make it mixed and have put together in one place. DataModule.qml: pragma Singleton import QtQuick QtObject { property string someString: "foo bar" function log(l) { MyCppInterface.log(l); } } And call it from anywhere: ApplicationWindow { id: mainWindow width: 640 height: 480 visible: true Component.onCompleted: { DataModule.log("test log"); } } Ideally, I would like to hide global access to MyCppInterface and have it only via DataModule. This could by probably possible via Qt.createQmlObject("MyCppInterface") or Qt.createComponent("MyCppInterface") or something like that inside DataModule {} but I'm very happy what I obtained so far and I like it :)
  • QML debugging does not show variable value on mouse hover

    Unsolved
    2
    0 Votes
    2 Posts
    169 Views
    mzimmersM
    I'm fairly sure that is normal. You can use the QML Debugger Console to look at simple values in QML. Maybe someone else can provide insight on how to do this with QML objects.
  • Loading an obj 3d model using Qt

    Unsolved
    4
    0 Votes
    4 Posts
    780 Views
    R
    The example is very useful. It uses RuntimeLoader https://doc.qt.io/qt-6/qml-qtquick3d-assetutils-runtimeloader.html . The sample project loads obj files successfully. But if I want to load fbx files, I might want to use balsam tool. This sample loads the obj file directly from the source at runtime. Is there anyway I can load fbx files runtime without using balsam tool? I think Quick 3d internally uses assimp, which loads multiple formats?
  • QML_FOREIGN does not work

    Unsolved
    1
    0 Votes
    1 Posts
    136 Views
    No one has replied
  • Endless loading in configuring new Quick app

    Unsolved
    1
    0 Votes
    1 Posts
    115 Views
    No one has replied
  • connecting cpp to qml

    Unsolved
    2
    0 Votes
    2 Posts
    176 Views
    Axel SpoerlA
    Please format your code, using the code formatting tags. In this function I'm getting all the bluetooth devices discovered No. You get the name of the device, the info of which has been passed as the device argument. the deviceList is a type of qvariant No. deviceList is a QString. It's neither a list (as the name wrongfully suggests), nor a QVariant. how to show it in qml list view I don't know about that. Please help me with the connection. A connection from what to what? Is Connection_Handler a slot, a Q_INVOKABLE, or the getter of a Q_PROPERTY? Have you actually tried to access it from QML?
  • Can't load phoenix.js library - Cannot read property 'WebSocket' of undefined

    Unsolved
    2
    0 Votes
    2 Posts
    242 Views
    K
    I found this topic: https://stackoverflow.com/questions/38935558/instantiate-browser-like-websocket-in-qml-js Seems like Qt QML JavaScript engine has cut out websockets which is understandable since QML has its own WebSocket component. Is there any workaround?
  • Data sent from CPP causes interface crash in QML

    Unsolved
    6
    0 Votes
    6 Posts
    489 Views
    SGaistS
    Well, since it crashes quickly with the debugger, you should already have a stack trace at hand to share with us.
  • QML Rotation for Scene and Mouse

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    L
    We've used Rotation, but doing that doesn't seem to rotate the popup context. It'd be great to have a solution that is external to the application.