Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.6k Posts
  • Help with QML code

    Unsolved
    3
    0 Votes
    3 Posts
    337 Views
    C
    @J-Hilk is right. It's printing on the console. However, if you want to move the container by pressing the left key try the following code. import QtQuick 2.6 import QtQuick.Window 2.2 Window { width: 640 height: 480 visible: true title: qsTr("Key Handling") Item { id: mainContainer Rectangle{ x:100; y:10 height: 100; width:100 radius: 20 color: "red" } focus : true Keys.onPressed: { if(event.key===Qt.Key_Left) { console.log("move left"); event.accepted= true; mainContainer.x-- } } Keys.onSelectPressed: console.log("Selected"); } }
  • QML Rectangle:Possible anchor loop detected on horizontal anchor.

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    Swati777999S
    @Markkyboy Just a doubt , whatever width or height was written inside the window, doesn't it define the dimension of the window?
  • Delegate not aligning Child without Anchors

    Unsolved
    7
    0 Votes
    7 Posts
    664 Views
    jeremy_kJ
    @SocketSackett said in Delegate not aligning Child without Anchors: @jeremy_k Yes. It is a sibling. Above you can see it is below the scrollbars of the TableView. I don't see any scrollbars. In the initial post, the HorizontalHeaderView is a child of the TableView. If that has been changed and it still doesn't work, post the updated code.
  • Instantiating QML Dialog from c++, "cannot find any window to open popup in"

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    SeDiS
    Solved. The error message, speaking about a "window", is a bit misleading, as we need to set not the window itself, but the window's contentItem() as a parent. For posterity, my working code: QQuickWindow *mainWindow = qobject_cast<QQuickWindow*>(m_engine->rootObjects().value(0)); QQmlComponent boxComp( m_engine, QUrl( "qrc:/UserInteractionBox.qml" ) ); QVariantMap initialProperties; initialProperties["parent"] = QVariant::fromValue(mainWindow->contentItem()); initialProperties["title"] = m_title; initialProperties["text"] = m_text; QQmlContext *ctxt = m_view->rootContext(); auto obj = boxComp.createWithInitialProperties(initialProperties,ctxt); QMetaObject::invokeMethod(obj, "open"); As for the Dialog, my starting point is simply: import QtQuick 2.0 import QtQuick.Controls 2.15 Dialog { id: userInteractionBox property string text: "" TextArea { anchors.fill: parent text: userInteractionBox.text } }
  • qmake Maximum statement or expression depth exceeded

    Solved
    3
    0 Votes
    3 Posts
    288 Views
    kkoehneK
    A quick fix for you might be to disable the Qt Quick Compiler / qmlcachegen. That is , if your application is based on qmake, do not pass or set the "qtquickcompiler" CONFIG option.
  • Redirect component to another container

    Solved
    3
    0 Votes
    3 Posts
    190 Views
    P
    This actually works! Thank you very much!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • Connect a camera with direct device ID

    Solved
    2
    0 Votes
    2 Posts
    355 Views
    A
    It was basic: deviceId: "/dev/video0" or deviceId: "/dev/video2" ... You can look at device id names on Ubuntu terminal with $ ls /dev/video* [image: 2bf0402b-fb7e-46ca-a358-93ab8acb42f9.png]
  • Native style

    Unsolved
    4
    0 Votes
    4 Posts
    320 Views
    SGaistS
    You can see directly in the code.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    23 Views
    No one has replied
  • Shadow remains when the part moves in a transparent window

    Unsolved
    1
    0 Votes
    1 Posts
    192 Views
    No one has replied
  • problem with updating c++ data in a QML file

    Unsolved
    6
    0 Votes
    6 Posts
    518 Views
    KroMignonK
    @dziko147 said in problem with updating c++ data in a QML file: No . Back is a Global variable defined in command.h (the headers where the connect is defined) . Global variable defined in header sounds strange to me. And, as @jsulm already wrote, in C++ there is no good reason to use global variable... In C it may be used, but in C++ avoid it! I don't know what are your skills in programming, but you don't seems to be an experimented programmer. Why do you not start with Qt examples and try to understand how it works? Then start to modify it to adapt it to your needs. Please take time to read this, at least: https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html
  • Setting the color of toolbar

    Solved
    3
    0 Votes
    3 Posts
    546 Views
    SandebsS
    I tried it now. Your proposed solution lets me set the color, thank you @Mammamia ! If anyone else has the same problem, here is what i did next to get the same shadow effect as you get by doing the setstyle("Material")-solution. Use Dropshadow: header: ToolBar { id: idToolBar anchors.left: parent.left anchors.right: parent.right contentHeight: toolButton.implicitHeight // A solution that works, but gives me some side effects to my program.. // Material.primary: "#002855" //"#003877" //Alternative solution //Set color to the toolbar background: Rectangle{ id: idToolbarColor color: JotronStyle.jDarkBlue //shadow beneath the toolbar DropShadow { anchors.fill: idToolbarColor verticalOffset: 1 radius: 8.0 samples: 16 source: idToolbarColor color: "#80000000" } }
  • How to create QtQuick widgets using a python "for" loop

    Unsolved
    10
    0 Votes
    10 Posts
    1k Views
    sierdzioS
    @cheesecake_factory said in How to create QtQuick widgets using a python "for" loop: @sierdzio I meant how to set up the signal and slot and thanks for pointing out my mistakes. "Repeater" could be used in this case but I want to send data to the QML file. For example, say I have a dictionary of an image link and its respective site link I want the app to display the image. How can I set it up like that? I don't know Python so I can't help on that front. But in QML, if you have some model or QObject attached as context root property to the engine, it can be quite easy. Column { Repeater { model: yourContextProperty.link.length Row { Text { text: "Oh hi! " + yourContextProperty.link[index] } Image { source: yourContextProperty.image[index] } } } } Where yourContextProperty is a QObject like: class MyObject : public QObject { Q_OBJECT Q_PROPERTY(QStringList link READ link NOTIFY linkChanged) Q_PROPERTY(QStringList image READ image NOTIFY imageChanged) public: // blah blah, the usual stuff QStringList link() const { return { "aaa.com", "bbb.com" }; } QStringList image() const; { return { ":/imageA,png", ":/imageB.png" }; } signals: void linkChanged() const; void imageChanged() const; }; And you add this object to engine like this: // main.cpp QQmlEngine engine; auto myObject = new MyObject(&engine); engine.rootContext()->setContextProperty("yourContextProperty", myObject);
  • Icon Dialog

    dialog icon
    12
    0 Votes
    12 Posts
    9k Views
    HackSawH
    @p3c0 said in Icon Dialog: @didu Icon specified through RC_ICONS will not be available at runtime in the code. It is used to set the icon for the executable which is created after compiling. In your case you need to store the icon in Qt's Resource System by creating a .qrc file. After that it will be accessible from the code. Eg: app.setWindowIcon(QIcon("qrc:/images/logo.ico")); Another quick way to test it ls loading the ico file from a physical location. Eg: app.setWindowIcon(QIcon("D:/MyIcons/logo.ico")); The above should work too. But a more practical approach is to use the Resource files. More info here. I was facing a similar issue with the icon being loaded successfully from its physical location but not from the resource file. So I tried app.setWindowIcon(QIcon(":/Images/IconFile.ico")); where "qrc" is removed which worked seamlessly.
  • QML Debugger with Mixed Mode was working but stopped working

    Unsolved
    2
    0 Votes
    2 Posts
    178 Views
    S
    This problem is related to the internal socket process crashing. I got it working again, but once I went to "Stop Debugger" in QML Debugger, it crashed the socket service; it didn't stop cleanly. Once again I can't connect to the socket. This is bizarre. This is Qt 5.15.5 & Windows 11.
  • QML Styling in Hybrid C++/QML application

    Unsolved
    5
    0 Votes
    5 Posts
    467 Views
    M
    @SocketSackett This might be due to QmlEngine failed to see where the qmldir is. here is my blog post and example of how to create a shared QML component library. https://arunpkqt.wordpress.com/2020/07/25/shared-qml-component-library/ We need to also pass the path to qmldir to the QQmlEngine to search for the installed modules. This path may be a local filesystem directory, a Qt Resource path (:/imports), a Qt Resource url (qrc:/imports) or a URL. As we have already included the qrc file in aforementioned step we could use 1 engine.addImportPath(":/imports"); 4. In the QML file import the module as 1 import com.apk.components 1.0 as Apk hope that helps!
  • qt 5.15.2 : module "QtGraphicalEffects" is not installed

    Unsolved
    1
    0 Votes
    1 Posts
    341 Views
    No one has replied
  • how can i access to SetContextProperty from Multiple classes

    Unsolved
    11
    0 Votes
    11 Posts
    785 Views
    D
    @jsulm ok now it's clear for me what should I do . thank you :)
  • How to use child camera in QML View3D (QT designer Studio)?

    Unsolved
    1
    0 Votes
    1 Posts
    147 Views
    No one has replied