Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
19.8k Topics 76.7k Posts
  • QML Debug error finding file

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    13 Posts
    2k Views
    A

    Hey @eternal_void , I just got back to using Qt for another project. This is new account (I was @talksik), but here are my findings in a similar post after a ton of research and coming up with a custom solution not really mentioned anywhere: https://forum.qt.io/post/821291

  • Custom C++ QML element with arguments

    Unsolved
    7
    0 Votes
    7 Posts
    600 Views
    A

    This has been a question of mine for over a year. I resorted to having a factory class that has methods to instantiate various view models (and pass in dependencies) and return the pointer to that view model. This factory would be exposed to QML via singleton or contextProperty at the start of my program. Any QML view can decide which view models it wants and doesn't deal with dependency injection.

    Here is an example:

    class ViewModelFactory : public QObject { Q_OBJECT QML_ELEMENT QML_SINGLETON public: Q_INVOKABLE HomeViewModel* createHomeViewModel(QObject* parent = nullptr) { // Inject dependencies from ApplicationModels auto& appModels = ApplicationModels::instance(); return new HomeViewModel(appModels.smartHomeService(), appModels.userService(), parent); } };

    Now, the above example makes ApplicationModels a singleton and passes it to the view model, but you could imagine a world where the factory can manage the dependencies without them being singletons.

    It took a lot of thinking and I gathered this approach by looking at how QtWidgets does things: a very hierarchical object structure where the MainWindow class would contain everything within it and proctor instantiation, DI, and more.

    QML just has access to what is publicly exposed by the ApplicationModel/factory, and no longer needs access to dependencies for ViewModels to use their desired view model.

    Note: I have not tested this yet (my fear being that I do NOT know the impact of calling factory methods on init of a Qml component)

  • Manage focus between multiple displays on Linux Wayland

    Unsolved
    2
    0 Votes
    2 Posts
    25 Views
    SGaistS

    Hi and welcome to devnet,

    Just a quick that came to mind: what about adding the primary screen widget as last ?

  • OpenSSL with QML Image source. Self signed ca-certificate

    Solved
    8
    1 Votes
    8 Posts
    1k Views
    A

    The error you're encountering ("QML Image: SSL handshake failed") typically happens when there's a problem establishing a secure connection between the QML application and the server you're trying to connect to. This is often caused by issues with SSL certificates, the server's configuration, or network problems. To resolve this error, you can try the following steps:

    Check SSL/TLS Configuration: Ensure that the server you're connecting to has a valid SSL certificate. If you're using a self-signed certificate, it may not be trusted by the system. Make sure the certificate is correctly installed.

    Update QML/Qt and SSL Libraries: Sometimes, outdated libraries can cause compatibility issues. Make sure you're using the latest version of QML, Qt, and SSL libraries (OpenSSL).

    Verify Network and Proxy Settings: If you're behind a proxy or firewall, ensure the settings are properly configured and not blocking the SSL handshake.

    Trust Certificates: If the certificate isn't recognized by the system, you may need to manually add the certificate to the trust store.

    Enable Debugging: You can enable debugging in Qt to get more information about the SSL handshake failure. Set the following environment variable before running your application:

    ini
    Copy
    Edit
    QT_DEBUG_PLUGINS=1
    For more detailed information and troubleshooting, you can refer to the following resources:

    Qt SSL documentation
    OpenSSL documentation
    Common SSL handshake errors
    Let me know if you need more help!

  • Sync QQuickPaintedItem and QML painting

    Solved
    3
    0 Votes
    3 Posts
    66 Views
    -

    Ah, didn't read this. Thanks for the hint...

  • qml with QQuickPaintedItem will slow down the ui operation

    Unsolved
    1
    0 Votes
    1 Posts
    18 Views
    No one has replied
  • picture locations

    Unsolved
    11
    0 Votes
    11 Posts
    239 Views
    B

    There was a similar question the other day and this was what I said:

    I recall having to try a few things when I first wanted to do this a few years ago. I don't know if what I arrived at is the "correct" approach, but the format that I found to work in QML and have stuck to ever since involves using a triple forward slash like this:

    source: "qrc:///images/my-image.png"

    As it's something that keeps popping up, I'd be interested to see some clarification on this from experts. I don't know if QML introduces any quirks above and beyond what is described in the resources chapter in the docs, which does not explicitly mention QML.

  • QML SelectionRectangle behavior change

    Unsolved
    1
    0 Votes
    1 Posts
    30 Views
    No one has replied
  • Correct way to deploy QML plugin with support of QDS

    Unsolved
    1
    0 Votes
    1 Posts
    30 Views
    No one has replied
  • STM32MP157C QT Quick portrait orientation

    Unsolved
    1
    0 Votes
    1 Posts
    40 Views
    No one has replied
  • 0 Votes
    3 Posts
    100 Views
    P

    Snipaste_2025-02-21_19-04-28.jpg
    The complete picture looks like this

  • Bug in qt 5.15.2: Button.checkable = false is gettin ignored

    Unsolved
    2
    0 Votes
    2 Posts
    76 Views
    MarkkyboyM

    Checkable and checked are not components of Button QML.

    A similar question here; https://forum.qt.io/topic/36479/solved-button-checkable-and-checked-not-working albeit a different answer/outcome from my response. Regardless, I still myself, cannot use checkable or checked with Button.

  • 0 Votes
    3 Posts
    69 Views
    S

    @SGaist Thank you so much!

  • 0 Votes
    2 Posts
    78 Views
    M

    It turns out wrapping the child Layout in an Item does the trick. Don't know why and whether this is the best solution

    import QtQuick import QtQuick.Controls import QtQuick.Layouts Window { height: 300 width: 240 visible: true StackLayout { anchors.fill: parent Item { Layout.fillWidth: true Layout.fillHeight: true ColumnLayout { anchors.fill: parent Rectangle { color: "red" Layout.preferredWidth: 100 Layout.preferredHeight: 50 Layout.alignment: Qt.AlignHCenter // Center within ColumnLayout } // other items } } // other items } }
  • 0 Votes
    6 Posts
    132 Views
    jsulmJ

    @VITORdk said in Error: ":\Qt\6.7.3\android_arm64_v8a\include\QtCore\qnamespace.:24:1: error: error: Parse error at "__attribute__"":

    So I reduced my file to an empty file

    You can't compile an empty file. Also, I guess your project consists of more than just an empty file.
    Please provide more information, else nobody knows what you're doing and what the problem is.
    Did you try to create a new widget project in QtCreator and build it for Android?

  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • 0 Votes
    1 Posts
    37 Views
    No one has replied
  • MapPolygon border color doesnt change on update

    Unsolved
    1
    0 Votes
    1 Posts
    28 Views
    No one has replied
  • No word suggestions on Android in TextEdit

    Solved
    6
    1 Votes
    6 Posts
    245 Views
    M

    Fixed in 6.8.2