跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.2k 貼文
  • Exceptions using InputPanel

    Unsolved
    4
    0 評價
    4 貼文
    609 瀏覽
    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 評價
    3 貼文
    281 瀏覽
    N
    @GrecKo , Thank you for the suggestion. I Have updated the same.
  • How to create a Tableview in which we can update the row and column dynamically through cpp?

    Unsolved
    1
    0 評價
    1 貼文
    107 瀏覽
    尚無回覆
  • Translations - No way to change language in runtime except with a blank string?

    Solved
    4
    0 評價
    4 貼文
    518 瀏覽
    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 評價
    2 貼文
    1k 瀏覽
    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 評價
    4 貼文
    943 瀏覽
    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 評價
    5 貼文
    369 瀏覽
    B
    @SGaist Thank you a lot!
  • ListModel Append Data Application is Crash

    Solved
    10
    0 評價
    10 貼文
    2k 瀏覽
    ?
    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 評價
    4 貼文
    417 瀏覽
    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 評價
    4 貼文
    1k 瀏覽
    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 .
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    1 瀏覽
    尚無回覆
  • How to use headerData as Model for HorizontalHeaderView if used with a QSortFilterProxyModel

    Unsolved
    2
    0 評價
    2 貼文
    234 瀏覽
    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 評價
    1 貼文
    124 瀏覽
    尚無回覆
  • Drawing dashed line in QQuickPaintedItem

    Unsolved
    2
    0 評價
    2 貼文
    244 瀏覽
    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 評價
    1 貼文
    594 瀏覽
    尚無回覆
  • QML components library with elegant styles

    Unsolved
    3
    0 評價
    3 貼文
    2k 瀏覽
    M
    Check this out: https://github.com/OlivierLDff/Qaterial
  • Know if an Item is the currentItem of a StackView

    Unsolved
    14
    0 評價
    14 貼文
    4k 瀏覽
    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 評價
    3 貼文
    471 瀏覽
    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 評價
    1 貼文
    166 瀏覽
    尚無回覆
  • Can't fit font to window

    Solved
    5
    0 評價
    5 貼文
    405 瀏覽
    P
    I removed functions onWidthChanged and onHeightChanged and next I used Qt.bindings and it works perfectly. Thanks @GrecKo MenuItem { checkable: true checked: true text: "Data" shortcut: "Ctrl+D" onTriggered: { if (checked == true) { text = "Data" dateLabel.visible = true timeLabel.width = Qt.binding(() => mainWindow.width); timeLabel.height = Qt.binding(() => mainWindow.height/2); onlyTime = false } else { text = "Data" dateLabel.visible = false timeLabel.width = Qt.binding(() => mainWindow.width); timeLabel.height = Qt.binding(() => mainWindow.height); onlyTime = true } } }