Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • qmlRegisterType still usable?

    Unsolved 12 Feb 2024, 03:08
    1 Votes
    7 Posts
    2k Views
    @Groundbounce said in qmlRegisterType still usable?: How do you connect C++ and QML? Like explained in the documentation: https://doc.qt.io/qt-6/qtqml-cppintegration-overview.html QtCompany will for sure not ditch C++ as QML is only for UI and some logic in the UI. Everything else is still C++.
  • 0 Votes
    8 Posts
    1k Views
    import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 Window { id: mainWindow visible: true width: 850 height: 360 minimumWidth: 350 minimumHeight: 620 title: "Flight Plan Dashboard" color: "#1e2130" property bool isHorizontal: width >= 700 ColumnLayout { anchors.fill: parent anchors.margins: 10 spacing: 10 GridLayout { id: mainContentGrid Layout.fillWidth: true Layout.fillHeight: true flow: isHorizontal ? GridLayout.LeftToRight : GridLayout.TopToBottom columns: isHorizontal ? 3 : 1 rows: isHorizontal ? 1 : 3 // Flight Plan Panel Rectangle { Layout.fillWidth: !isHorizontal Layout.preferredWidth: isHorizontal ? mainWindow.width * 0.25 : -1 Layout.preferredHeight: isHorizontal ? mainWindow.height - 20 : 100 color: "#282c3e" radius: 5 ColumnLayout { anchors.fill: parent anchors.margins: 12 spacing: 6 Text { text: "Flight Plan 1.0" font.pixelSize: 14 font.bold: true color: "white" } Text { text: "26 Nov 06:43Z" font.pixelSize: 12 color: "#a0a0a0" } Text { text: "KRISTINA-SOLI" font.pixelSize: 14 font.bold: true color: "white" Layout.topMargin: 4 } Text { text: "4047154622*79502/0B" font.pixelSize: 12 color: "#a0a0a0" } Item { Layout.fillHeight: true } } } // Crew Panel Rectangle { Layout.fillWidth: !isHorizontal Layout.preferredWidth: isHorizontal ? mainWindow.width * 0.35 : -1 Layout.preferredHeight: isHorizontal ? mainWindow.height - 20 : 180 color: "#282c3e" radius: 5 ColumnLayout { anchors.fill: parent anchors.margins: 12 spacing: 6 Text { text: "Crew" font.pixelSize: 14 font.bold: true color: "white" } RowLayout { spacing: 6 Text { text: "Flight Deck" font.pixelSize: 12 color: "#a0a0a0" } Rectangle { Layout.preferredWidth: 20 Layout.preferredHeight: 20 radius: 10 color: "#4a5064" Text { anchors.centerIn: parent text: "2" color: "white" font.pixelSize: 10 } } Text { text: "Cabin" font.pixelSize: 12 color: "#a0a0a0" Layout.leftMargin: 8 } Rectangle { Layout.preferredWidth: 20 Layout.preferredHeight: 20 radius: 10 color: "#4a5064" Text { anchors.centerIn: parent text: "4" color: "white" font.pixelSize: 10 } } } Repeater { model: isHorizontal ? 2 : 3 delegate: Rectangle { Layout.fillWidth: true Layout.preferredHeight: 30 color: "transparent" border.color: "#444" border.width: 1 radius: 4 Layout.topMargin: 4 RowLayout { anchors.fill: parent anchors.margins: 6 spacing: 8 Rectangle { Layout.preferredWidth: 20 Layout.preferredHeight: 20 radius: 10 color: "#4a5064" Text { anchors.centerIn: parent text: "👤" color: "white" font.pixelSize: 12 } } Text { text: { if (index === 0) return "CRAIG M GIFFORD"; if (index === 1) return "COLIN P ZIMMERM..."; if (index === 2) return "CHRISTY L ALLEN"; return ""; } color: "white" font.pixelSize: 12 } } } } Item { Layout.fillHeight: true } } } // Aircraft Status Panel with FMS INIT & FA ColumnLayout { Layout.fillWidth: !isHorizontal Layout.preferredWidth: isHorizontal ? mainWindow.width * 0.4 - 30 : -1 Layout.preferredHeight: isHorizontal ? mainWindow.height - 20 : -1 spacing: 6 Rectangle { Layout.fillWidth: true Layout.preferredHeight: 200 color: "#282c3e" radius: 5 ColumnLayout { anchors.fill: parent anchors.margins: 12 spacing: 6 Text { text: "Aircraft Status" font.pixelSize: 14 font.bold: true color: "white" } Text { text: "N542DE / DL375" font.pixelSize: 14 font.bold: true color: "white" Layout.topMargin: 4 } Text { text: "A21N" font.pixelSize: 12 color: "#a0a0a0" } Item { Layout.fillHeight: true } } } RowLayout { Layout.fillWidth: true spacing: 10 Rectangle { Layout.fillWidth: true Layout.preferredHeight: (mainWindow.width * 0.4 - 50) / 3 color: "#343747" radius: 4 Text { anchors.centerIn: parent text: "FMS INIT" color: "white" font.pixelSize: 12 } } Rectangle { Layout.fillWidth: true Layout.preferredHeight: (mainWindow.width * 0.4 - 50) / 3 color: "#343747" radius: 4 Text { anchors.centerIn: parent text: "FA" color: "white" font.pixelSize: 12 } } } } } } }
  • 0 Votes
    3 Posts
    728 Views
    Hi! This is my problrem too any advice? :(
  • 0 Votes
    2 Posts
    279 Views
    Hi and welcome to devnet, Where are you using Qt in your system ? As per your code, I would say never so it would be better if you explained exactly what runs where and what exactly are you using.
  • 0 Votes
    2 Posts
    285 Views
    Solution was mostly there and fix appeared very simple: move anchors margins from _fillHeight property calculations to readonly property bool _fillHeight: { let bottom = mapToItem(applicationWindow.contentItem, 0, implicitHeight).y; return bottom > applicationWindow.height } frame.implicitHeight property: implicitHeight: frameColumn.implicitHeight + defaultPixelHeight * 4 Now everything works and looks fine! No errors or binding loops.
  • How do the "QML" and "QMLScene" tools differ?

    Solved 19 Apr 2025, 09:06
    0 Votes
    2 Posts
    254 Views
    @RokeJulianLockhart, interest.qt-project.narkive.com/p4tyYKC9 states: The QML tool is a bit more flexible, makes fewer assumptions (e.g. it doesn’t use a QApplication by default, so you don’t end up loading the widgets module into memory if you don’t need it) and is meant as the long-term replacement for qmlscene. QML can be used for non-graphical purposes if your root object is a plain QObject, not an Item or Window; that’s only practical with the qml tool, not qmlscene. It is more directly analogous to other language interpreters like python and perl (which also do not load graphical libraries unless you import the relevant modules in your script), and you can even use the shebang mechanism, so that qml files can be marked executable and run from the command line. You can configure your window system to use it as the default application with which to run any file with the qml extension (e.g. when double-clicking a qml file in your file manager/finder), if you like. (QTBUG-33659 is a request to set up that association when you install the SDK, but that never got done AFAIK. It requires someone with Qt Installer expertise, I think.) So you could nearly forget about qmlscene, except that it has a few handy command-line options that qml still doesn’t.
  • 0 Votes
    1 Posts
    123 Views
    No one has replied
  • 0 Votes
    3 Posts
    434 Views
    Thanks, but: @Rangantha-B-V said in Custom TextField existing required property not initialized, but it is: implicitWidth exists on Item and is read-only (computed internally based on content/layout hints). I disagree. The doc does not write that the property is read-only. It says that "however some items have an inherent implicit size which cannot be overridden, for example, Image and Text", which I assume is the case of the TextInput, but is not really mentioned precisely in the doc... As a counter-example to read-only, you can set an implicitWidth with a ComboBox and with a TextField. The ComboBox can have a required on implicitWidth without any problems, which is not the case of TextField, why that ? @Rangantha-B-V said in Custom TextField existing required property not initialized, but it is: bind to width or implicitWidth internally So it's read-only from the outside but editable within the object ? In this case, why could I set it from the outside by simply removing the required line ?
  • 1 Votes
    3 Posts
    416 Views
    https://forum.qt.io/topic/161751/qt6-gstreamer-cmake/2?_=1744802661208
  • Make Image Round

    Unsolved 16 Apr 2025, 05:00
    0 Votes
    7 Posts
    443 Views
    @J.Hilk yes I am sure, but apparently android is not rendering the images when I apply it, however this workaround that I mention worked for me finally.
  • 1 Votes
    11 Posts
    1k Views
    @Aleksey_K said in QML runtime error: module "Qt5Compat.QtGraphicalEffects" is not installed: Unfortunate MultiEffect is buggy comparing to ColorOverlay - it does not color my icon in some cases, so forced to rollback to Qt5Compat.GraphicalEffects. Found solution for the full replacement: https://forum.qt.io/post/807844 Need to set brightness: 1.0, however now "transparent" color does not work if I need to keep original color unchanged, Probably need to add more complex logic to hide MultiEffect and show original Image. So still on ColorOverlay.
  • 0 Votes
    8 Posts
    922 Views
    There's also Slate - Pixel Art Editor Scrite - Screenwriting app
  • qml TableView top left corner

    Unsolved 14 Apr 2025, 22:02
    0 Votes
    1 Posts
    131 Views
    No one has replied
  • Getting error vector subscript out of Range

    Unsolved 11 Apr 2025, 16:59
    0 Votes
    3 Posts
    313 Views
    @SGaist said in Getting error vector subscript out of Range: Use the debugger to see exactly where it is happening. To do that, click on "Retry".
  • Installing a reusable QML module

    Unsolved 13 Apr 2025, 00:15
    0 Votes
    1 Posts
    156 Views
    No one has replied
  • Listview Populate Transition Interrupted

    Solved 8 Apr 2025, 21:31
    0 Votes
    2 Posts
    356 Views
    Hello again! After some digging, I’ve found an "elegant" solution. First, setting the NumberAnimation with a duration of 500 (population animation) was interfering with the hover animation duration (Delegate), which is 300. That was causing some weird behavior. The second part is that I added the property change in the "" state, which fixed the issue and now the element returns to its original position even if the animation gets interrupted. states: [ State { name: "zoomed" PropertyChanges { target: test_delegate scale: zoomedScale rotation: zoomedRotation } }, State { name: "" PropertyChanges { target: test_delegate scale: normalScale rotation: normalRotation } } ]
  • 0 Votes
    4 Posts
    372 Views
    @IamSumit what if you add to your code visibility: Window.FullScreen
  • QtGraphs Bug

    Unsolved qtgraphs pyside6 10 Apr 2025, 18:44
    0 Votes
    5 Posts
    502 Views
    @jsulm @jsulm said in QtGraphs Bug: Look at these numbers. I doubt this is what you added. Yes, I agree the numbers are output strangely. @jsulm said in QtGraphs Bug: run the app in a terminal, then you should see the Python exception. Perhaps I don't have enough knowledge, I would be glad if you could explain how a regular terminal differs from a terminal in VS Code. I don't understand what new things I'll be able to see. I also see python exceptions in the VS Code terminal, but they were not noticed in this code. In any case, how can you explain that the same code works without problems when replacing QSplineSeries with QLineSeries, I attach a screenshot of an example of the work. [image: 33a49b14-9ee0-4b70-94c0-553c878b7d13.png]
  • 0 Votes
    3 Posts
    292 Views
    Thanks for your reply and the hint with the proxy model. A good working solution was now implemented using the following design: One AbstractListModel holding all the data A SortFilterProxyModel to filter the data based on the page number is instanciated for each page, using the Repeater + Loader inside of the SwipeModel The source component of the Loader holds a ListView that is using the ProxyModel as a model
  • ApplicationWindow size policy?

    Unsolved 10 Apr 2025, 18:31
    0 Votes
    1 Posts
    156 Views
    No one has replied