Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • 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
    607 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
    490 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
  • Can't fit font to window

    Solved
    5
    0 Votes
    5 Posts
    416 Views
    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 } } }
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    17 Views
  • Why MapQuickItem doesn't have bearing property?

    Solved
    2
    0 Votes
    2 Posts
    296 Views
    AlienA
    You can use transform in mapquickitem
  • Focus - Strange behaviors, sometimes the focus become inconsistent

    Solved
    2
    0 Votes
    2 Posts
    271 Views
    jeremy_kJ
    According to Focus Management in Qt Quick Controls, both SwipeView and Page act as focus scopes. In the second example, I don't see any explicit setting of focus in either one. If I assign ids to both of them, and bind txTextEdit to swipeView.focus + " " + page.focus, the initial value I see is "false true". Assigning true to swipeView.focus causes txTextEdit to have active focus. Without assigning focus to the SwipeView, clicking on the TextEdit causes the SwipeView to gain focus. The same thing happens with an initial tab press. Tabbing again goes to the OK Button, and then to Cancel. It doesn't continue cycling after that. Shift-tab runs in the reverse order, and does cycle. I'm not sure what causes the difference. Adding KeyNavigation.tab: txTextEdit to the cancel button allows navigation with tab to loop. This is with Qt 5.15.0 on macOS, QtQuick 2.15, QtQuick.Window 2.15, and QtQuick.Controls 2.12. It's possible that other versions have different intentional, undefined, or defective behavior.
  • 0 Votes
    3 Posts
    1k Views
    jeanmilostJ
    @LeLev Thank you very much for your answer. It helped me to understand my issue a little more. So I tried your code, and it works, meaning that the ListView isn't eating the Space key. However my interface is a little more complex than this one, it contains other objects like SwipeView, and yes, my items contain components like buttons which may take the focus. However I already tried to deactivate them and even thus the issue remained. I played a while around the code you posted. I noticed that the following code no longer receives any key: Rectangle { anchors.fill: parent color: "transparent" visible: true SwipeView { anchors.fill: parent activeFocusOnTab: false Page { background: null ListView { id: view anchors.fill: parent spacing: 2 focus: true model: ListModel { ListElement { name: "el1" } ListElement { name: "el2" } ListElement { name: "el3" } } delegate: Button { focus: false focusPolicy: Qt.NoFocus onFocusChanged: {if (focus) focus = false;} width: parent.width height: 50 text: index === view.currentIndex ? "currentIndex" : modelData onClicked: { view.currentIndex = index } } Keys.onPressed: { console.warn("key clicked"); if (event.key === Qt.Key_Space) { console.log("space clicked"); console.log(view.model.get(view.currentIndex).name); // view.model.get(ind).name = "new value" event.accepted = true; } } } } } } So I assume that some components operate like filters and may stop internally the keyboard signals, or at least a part of them, without let the choice to the developer to bypass this behavior (or at least I don't know how to do). To be honest I'm a little puzzled, because I worked for15 years with the Windows API before changing for Qt, and receiving a keyboard notification was never an issue, even when the parent component already received it before (in fact it was the contrary: the message could be blocked in the parent, but by default it was passing). So now the question is: in the above code, how can I receive the keyboard signals, and in particular the Space key, in my ListView despite of the parent SwipeView? Or which solution is normally used in a such situation, e.g is there a way to globally listen the keyboard and intercept keys in the Windows level, BEFORE any component receives them?
  • How to expose enum in class to QML

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    S
    Maybe I was not clear in the last post. I got rid of context property complete and only registered the type with qmlRegisterSingletonInstance. Now just wonder why creator complains about the import even if all the code works fine.
  • requestSize in QQuickImageProvider requestImage is always (-1, -1)

    Unsolved
    2
    0 Votes
    2 Posts
    212 Views
    KroMignonK
    @EmilieG I think you want to show picture into a Image QML item. So you have to use sourceSize, otherwise, the image returned by image provider will be scaled. For example Image { source: "image://myProvider/imagename" sourceSize: Qt.size(width, height) }
  • Flickable with Scrollbar Touch Issues

    Moved Solved
    3
    0 Votes
    3 Posts
    679 Views
    R
    Submitted to Qt support...response was: Thank you for contacting Qt Support, If your embedded device uses touch screen, the input for scrollbar is disabled when a touch input is used as it's not really practical and and flicking the view is usually preferred with touch input. However, if you attach a mouse to your device the input works for scrollbar is it mainly ignoring the input that is not coming from a genuine mouse, but accepts it when a real mouse is used. Does this make sense to you? ---------------8<-------------------------------------------- I read this as for touch a scrollbar is basically a scroll indicator.
  • QML Text Resized and Centered

    Solved
    2
    0 Votes
    2 Posts
    275 Views
    fcarneyF
    Doh, another post had an example of what I wanted: horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter
  • 0 Votes
    12 Posts
    2k Views
    Pablo J. RoginaP
    @Jimit-Rupani said in I'm trying to call a C++ function from qml to read a csv and enter that data into sql table, but it freezes the UI.: resolved so please don't forget to mark your post as solved!
  • mapboxgl dont work

    Unsolved
    2
    0 Votes
    2 Posts
    238 Views
    Pablo J. RoginaP
    @agunggumilang please don't double post.
  • Where to get example of a classic Table in Controls 2 (5.15)

    Unsolved
    1
    1 Votes
    1 Posts
    184 Views
    No one has replied