Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • left-hand side of assignment operator is not an lvalue

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    ODБOïO
    hi You use "play" as property name and button id
  • Exceptions using InputPanel

    Unsolved
    4
    0 Votes
    4 Posts
    647 Views
    fcarneyF
    What happens if you use QApplication instead of QGuiApplication in your main.cpp? I have run into quite a few QML objects that will crash the program if using QGuiApplication.
  • 0 Votes
    3 Posts
    293 Views
    N
    @GrecKo , Thank you for the suggestion. I Have updated the same.
  • 0 Votes
    1 Posts
    107 Views
    No one has replied
  • Translations - No way to change language in runtime except with a blank string?

    Solved
    4
    0 Votes
    4 Posts
    531 Views
    sierdzioS
    @jeanmilost said in Translations - No way to change language in runtime except with a blank string?: This refreshes all bindings. though (not only texts), which might be suboptimal (using empty string hack will have better performance). But best test this in your app and decide for yourself. On another side, using the string hack may be more complicated to maintain in a huge project (e.g easy to forget empty strings on several translations), in addition to generate several side effects in my project (e.g I see qsTr("MyCaption") + WTranslation.emptyString in every component on my designer instead of just MyCaption). So if the performance isn't too bad, I will clearly favorise this option over the string hack. Of course, these are good arguments. I don't know your project, of course, but in a general case users would not be unhappy even if language switch was slow (1-3 seconds), it should be enough to add a loading popup or something. How it will be in practice, depends of course. Depending on how screens are loaded and general app architecture, there can be thousands of active bindings, or just a few dozen. In an optimistic case reevaluation of them all will take mere miliseconds.
  • 0 Votes
    2 Posts
    1k Views
    A
    For someone facing a similar issue, I did not find a direct solution, According to the table https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#sequence-type-to-javascript-array QList<CustomClass> is not yet supported in QML. Due to this reason I had to convert the QList<QList<CustomClass>> to QVariantMap<string,QVariantList<QVariantList<QVariantMap>>> And while using the values in qml use the bracket notation instead of the dot notation.
  • Setting/Disabling shortcuts

    Unsolved
    4
    0 Votes
    4 Posts
    966 Views
    jsulmJ
    @RobM You can subclass widgets you want to use and reimplement https://doc.qt.io/qt-5/qwidget.html#keyPressEvent Keep in mind that to overwrite Tab and Shift+Tab you have to overwrite https://doc.qt.io/qt-5/qwidget.html#event See https://doc.qt.io/qt-5/qwidget.html#events
  • Qt Widgets in Qt Quick application

    Solved
    5
    0 Votes
    5 Posts
    380 Views
    B
    @SGaist Thank you a lot!
  • ListModel Append Data Application is Crash

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    ?
    It's work var tmpData = JSON.parse(xhr.responseText.replace(/null/g, '""')) if(tmpData[z].games[d].videoId === null || tmpData[z].games[d].videoId === undefined || tmpData[z].games[d].videoId === "") { tmpData[z].games[d].videoId = 0 }
  • Qt6 and Custom QQuickItem - how to use updatePaintNode

    Solved
    4
    0 Votes
    4 Posts
    430 Views
    SGaistS
    Great then please mark the thread as solved using the "Topic Tools" button or the three doted menu beside the answer you deem correct so that other forum users may know a solution has been found :-)
  • QML Custom Shape Clip

    Unsolved
    4
    0 Votes
    4 Posts
    2k Views
    DanimaD
    @Danima basically according to tree dump the problem is that the CircleClip child is not descendant of ClipNode. QQuickItem for each item create one TransformNode to map coordinate system. All item's children are descendant of TransformNode. I want a way to some thing like replace or embed ClipNode with TransformNode .
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • 0 Votes
    2 Posts
    241 Views
    M
    Hm, actually it seems that it is working as intended in 5.15.1 but not so in 5.15.0
  • ColorOverlay render in QtCreator Designer

    Unsolved
    1
    0 Votes
    1 Posts
    125 Views
    No one has replied
  • Drawing dashed line in QQuickPaintedItem

    Unsolved
    2
    0 Votes
    2 Posts
    258 Views
    sierdzioS
    Well, divide your work into 3 separate parts: draw the first part using normal line draw the middle bit using dashed line draw the rest using normal line again. To modify line style, use QPen.
  • Qt 5.14.2 - Advices about MouseArea and DragHandler

    Unsolved
    1
    0 Votes
    1 Posts
    603 Views
    No one has replied
  • QML components library with elegant styles

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    M
    Check this out: https://github.com/OlivierLDff/Qaterial
  • Know if an Item is the currentItem of a StackView

    Unsolved
    14
    0 Votes
    14 Posts
    4k Views
    DiracsbracketD
    @GrecKo said in Know if an Item is the currentItem of a StackView: That's not why it doesn't work. I mentionned why in the post above You're right. That indeed simplifies things... Thanks!
  • Horizontalheaderview with QSortFilterProxyModel

    Solved
    3
    0 Votes
    3 Posts
    489 Views
    M
    In case someone wants to reproduce this: headers are displayed correctly if if use tableModel in the qml file, and it stops working if I use sortModel main.qml import QtQuick 2.15 import QtQuick.Window 2.15 import Qt.labs.qmlmodels 1.0 import QtQuick.Controls 2.15 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") HorizontalHeaderView { id: horizontalHeader syncView: tableView anchors.left: tableView.left } VerticalHeaderView { id: verticalHeaderView syncView: tableView anchors.right: tableView.left anchors.top: tableView.top } TableView { id: tableView anchors.fill: parent anchors.margins: 50 model: sortModel delegate: Rectangle { width: 30 height: 30 border.color: "black" Text{ color: "black" text: model.display } } } } main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QSortFilterProxyModel> #include "tablemodel.h" int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); TableModel tm; engine.rootContext()->setContextProperty("tableModel",&tm); QSortFilterProxyModel sortModel; sortModel.setSourceModel(&tm); engine.rootContext()->setContextProperty("sortModel",&sortModel); engine.load(url); return app.exec(); } tablemodel.h #ifndef TABLEMODEL_H #define TABLEMODEL_H #include <QAbstractTableModel> class TableModel : public QAbstractTableModel { Q_OBJECT public: explicit TableModel(QObject *parent = nullptr); // Header: QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; // Basic functionality: int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; private: }; #endif // TABLEMODEL_H tablemodel.cpp #include "tablemodel.h" TableModel::TableModel(QObject *parent) : QAbstractTableModel(parent) { } QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const { return section; } int TableModel::rowCount(const QModelIndex &parent) const { if (parent.isValid()) return 0; return 5; } int TableModel::columnCount(const QModelIndex &parent) const { if (parent.isValid()) return 0; return 7; } QVariant TableModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); return QVariant::fromValue(QString::number(index.row())+","+QString::number(index.column())); }
  • Why cursor is moved to 0,0 when I use setGeometry?

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