Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • QML ListView: error when change width of delegate

    Unsolved
    3
    0 Votes
    3 Posts
    502 Views
    J
    I try what you suggest but originX and contentX is the same
  • How to create MapArc on Qtlocation map?

    Unsolved
    2
    0 Votes
    2 Posts
    234 Views
    No one has replied
  • Unsupported format encountered (obj) - QT3D Mesh

    Solved qt3d qmesh qml qt5.10 3drender
    3
    0 Votes
    3 Posts
    1k Views
    SGaistS
    Hi, Good catch ! I just remembered that there was an issue in earlier versions where the deployment tool didn't properly copy all the needed plugins. It has been fixed in between.
  • How to truncate a text of a button with a fade out effect?

    Solved
    2
    0 Votes
    2 Posts
    851 Views
    a.burksA
    This is my solution: First I had to customize my button. It's important to adjust the alignment for long text values, that should be clipped. Button { id: myButton text: model.label contentItem: Column { Image { ... } Label { width: myButton.width - innerSpacing horizontalAlignment: contentWidth > myButton.width - innerSpacing ? Text.AlignLeft : Text.AlignHCenter text: myButton.text clip: true } } } Than I have to add a visual effect: LinearGradient { height: myButton.height width: myButton.width start: Qt.point(parent.width - innerSpacing) end: Qt.point(parent.width,0) gradient: Gradient { GradientStop { position: 0.0 color: "#00000000" // tranparency } GradientStop { position: 1.0 color: "#FF000000" } } }
  • Using null in QML

    Unsolved
    4
    0 Votes
    4 Posts
    7k Views
    ODБOïO
    @Circuits said in Using null in QML: Is it even necessary in the QML world? Can I just leave it uninitialized like so: property var X; no, it is undefined if you let it uninitialized.you can test it property var undefinedVar Component.onCompleted: console.log(undefinedVar) // output > qml: undefined
  • How to add business logic to a QT Design Studio generated .ui.qml component

    Unsolved
    3
    0 Votes
    3 Posts
    483 Views
    leenamiettinenL
    We have some instructions about converting Qt Design Studio projects into Qt Quick Applications in the documentation here: https://doc.qt.io/qtdesignstudio/quick-converting-ui-projects.html
  • This topic is deleted!

    Moved Unsolved
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • 0 Votes
    2 Posts
    418 Views
    JonBJ
    @Ahti Perhaps not relevant, but can't help noticing: your removeRows and its call to beginRemoveRows() correctly allows for multiple rows, but your call to response = model->removeRow(first, QModelIndex()); only allows for one row. That's works for your del_row(), but not in general. I don't suppose fixing that changes behaviour?
  • QT/QML Testing

    Solved
    4
    0 Votes
    4 Posts
    431 Views
    sierdzioS
    I don't know it but I don't suppose it will allow you to test QML. It is a different language, after all.
  • 0 Votes
    1 Posts
    153 Views
    No one has replied
  • QML Progress Bar value not getting updated

    Unsolved
    11
    0 Votes
    11 Posts
    2k Views
    M
    @KroMignon I tried the event dispatcher the problem still exist. The progress bar only updates once
  • How to update QML Items from non-main thread in C++ correct way?

    Unsolved multithreading qml c++
    3
    0 Votes
    3 Posts
    2k Views
    6thC6
    I'd be careful just because of my own assumptions / experience, it sounds like you're setting up a landmine for later, I don't know because I just skimmed your issues, I can't tell enough for a proper context but I can recall the bug report that I found when I did. You might find this useful too: https://bugreports.qt.io/browse/QTBUG-43230 Ulf Hermann added a comment - 18 Mar '19 9:19 PM Note that exposing objects that live in a different thread as the QML engine via context properties is dangerous to begin with. You cannot safely access properties or call methods of such objects from QML. I really recommend proxying the signals through a separate object that lives in the engine thread. Ulf Hermann added a comment - 30 Apr '19 10:02 PM The bad idea is not actually the connection. The fact that the connection behaves in the way described here is just the consequence of the fact that you're exposing an object from a different thread. The QML language has no concept of threads (besides WorkerScript, but that is a different beast), so exposing the C++ threading model to it via context properties is a bad idea. The engine does not magically provide thread safety for otherwise unsafe operations and it needs to inspect the objects given to it as context properties. Please make sure everything you expose to a particular engine lives in the same thread. Otherwise all bets are off anyway.
  • XmlListModel issue

    Solved
    2
    0 Votes
    2 Posts
    141 Views
    xavi-bX
    Answer here: https://stackoverflow.com/questions/59869179/xmllistmodel-issue-when-fetching-from-the-google-contacts-api-xml
  • Pass parameters from QML to C++

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    ODБOïO
    @celica said in Pass parameters from QML to C++: double myhour = v_hour->property("hourcode").toDouble(); you can ensure conversion happened correctly if you pass a bool to toDouble https://doc.qt.io/qt-5/qstring.html#toDouble
  • Cannot work with components imported from QT Design Studio

    Unsolved
    2
    0 Votes
    2 Posts
    777 Views
    T
    Qt Creator can also open the projects from Qt Design Studio (.qmlproject). The imports and path should not require any changes, even if you integrate the .qmlproject into a C++ application.
  • How to use text with 2 font family in single line

    Solved
    2
    0 Votes
    2 Posts
    219 Views
    IntruderExcluderI
    Create a separate component extending Item and use Row or RowLayout as container. Add two Text elements to container and use property aliases in main Item to set text for each Text into container.
  • 0 Votes
    2 Posts
    537 Views
    sierdzioS
    @Ahti said in Inconsistency between model and view after removing a row from a table: JsonObject u_data; u_data.insert("id", model->record(index.row()).value(0).toInt()); u_data.insert("name", model->record(index.row()).value(1).toString()); if (role == Qt::DisplayRole) return u_data; That's inefficient. If you only support DisplayRole, then you can move that QJsonObject directly into that if statement. if (role == Qt::DisplayRole) { QJsonObject u_data; u_data.insert("id", model->record(index.row()).value(0).toInt()); u_data.insert("name", model->record(index.row()).value(1).toString()); return u_data; } Second, you should use the parent here, even if it is a flat list: beginRemoveRows(QModelIndex(), first, last); response = model->removeRow(first, QModelIndex()); beginRemoveRows(parent, first, last); response = model->removeRow(first, parent); But why you get this strange behavior when removing - I don't know. Perhaps it has something to do with the fact that you have two models here - UseModel is a list model and your model variable is a QSqlTableModel (which inherits from the same base class as list model). Perhaps these calls get duplicated, although it is unlikely. Try adding some qDebug() calls into removeRows(), or run it through a debugger, to see what is happening.
  • Issue using QQuickWidget with a resource qml file in a plugin

    Solved
    2
    0 Votes
    2 Posts
    651 Views
    xavi-bX
    Solution is to use: this->setSource(QUrl("qrc:/qml/MyQmlFile.qml")); QUrl apparently needs qrc:/ and not just :/
  • MouseArea cursorShape with a custom BitmapCursor

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    IntruderExcluderI
    As a superfast solution you can create a custom class which extends QQuickItem: class ParentCursorChanger : public QQuickItem { Q_OBJECT public: explicit ParentCursorChanger(QQuickItem* parent = nullptr) : QQuickItem(parent) {} public slots: void setBitmapCursor(const QString& path) { QPixmap p(path); QCursor c(p); qobject_cast<QQuickItem*>(parent())->setCursor(c); } }; Register it the same way as I posted before and do something like this in QML: MouseArea { anchors.fill: parent CursorChanger { Component.onCompleted: setBitmapCursor(":/images/cur1.png") } } But the super true way would be using attached properties ofcourse.
  • Row of Text items in ListView

    Solved
    18
    0 Votes
    18 Posts
    3k Views
    B
    @IntruderExcluder Thank you! I thought I had tried that one but obviously not. Anyway, it works well. Thank you for this and for your original suggestion.