Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
19.9k Topics 76.7k Posts
  • FontLoader not loading woff2 format

    Unsolved
    5
    0 Votes
    5 Posts
    125 Views
    M

    I tried but it doesn't even work in local to be honest

    FontLoader {id: myfont; source: "qrc:/static/BigShouldersStencil_18pt-Black.ttf"}

    QML FontLoader: Cannot load font: "qrc:/static/BigShouldersStencil_18pt-Black.ttf"

    You are supposed to be able to load from the internet or from loca, but none of them work for me: https://doc.qt.io/qt-6/qtquick-text-example.html#fonts

  • customize my ApplicationWindows in Qml

    Unsolved
    5
    0 Votes
    5 Posts
    70 Views
    S

    ok thanks

  • Connect cpp signal to qml registered cpp class

    Unsolved
    3
    0 Votes
    3 Posts
    134 Views
    S
    Modify dataGenerator Signal:
    Qt does not allow non-const references (&) in signals for queued connections. Modify the signal to use a const reference:

    cpp
    Copy
    Edit
    class dataGenerator : public QObject {
    Q_OBJECT
    signals:
    void DataChunkGenerated(const QVector<double> &dataChunk); // Use const reference
    };
    2. Ensure dataDisplay Slot Matches the Signature:
    Your dataDisplay class already has:

    cpp
    Copy
    Edit
    class dataDisplay : public QObject {
    Q_OBJECT
    public slots:
    void updateData(const QVector<double> &dataChunk);
    };
    This matches the modified signal.

    Connect the Signal to the Slot in C++:
    You can establish the connection in main.cpp or wherever you create these objects:

    cpp
    Copy
    Edit
    dataGenerator *generator = new dataGenerator();
    dataDisplay *display = new dataDisplay();

    // Connecting the signal from dataGenerator to the slot in dataDisplay
    QObject::connect(generator, &dataGenerator::DataChunkGenerated,
    display, &dataDisplay::updateData);

  • Custom ComboBox not scrolling

    Unsolved
    2
    0 Votes
    2 Posts
    99 Views
    S

    It seems the issue you're experiencing with the ComboBox not scrolling when there are many items is due to the absence of proper height configuration for the ListView inside the Popup. The ListView needs an explicit height to trigger scrolling behavior, and without it, the dropdown won't scroll even when there are many items.

    To fix this, you can add a fixed or constrained height to the ListView, and ensure the ScrollIndicator appears when needed. Here's the updated code for the popup section:

    popup: Popup {
    y: control.height - 1

    width: control.width implicitHeight: contentItem.implicitHeight padding: 0 contentItem: ListView { width: parent.width height: Math.min(200, contentHeight) // Constrain the ListView height or set a max height clip: true model: control.popup.visible ? control.delegateModel : null currentIndex: control.highlightedIndex ScrollIndicator.vertical: ScrollIndicator { visible: contentHeight > height // Only show the scroll indicator if the content exceeds the viewable area } } background: Rectangle { radius: 0 color: Qt.color(AppTheme.colors["UFO_ComboBox_Popup_Background"]) border.color: Qt.color(AppTheme.colors["UFO_ComboBox_DropBox_Border"]) }

    }

  • qml type annotation with local enum

    Unsolved
    2
    0 Votes
    2 Posts
    56 Views
    S

    I see the issue with your QML enum usage. In QML, you can't directly use an enum as a parameter type the way you're trying to do. Here's how to fix it:

    Solution 1: Use int as the parameter type while keeping the enum:
    qml
    enum States { State0, State1, State2 }

    function getSomething(id: int): string {
    if (id === States.State0) return "This is State0";
    if (id === States.State1) return "This is State1";
    if (id === States.State2) return "This is State2";
    return "Unknown state";
    }

    Solution 2: Define the enum in a more QML-friendly way:
    // In a separate file, e.g., States.qml
    pragma Singleton
    import QtQml 2.15

    QtObject {
    readonly property int State0: 0
    readonly property int State1: 1
    readonly property int State2: 2
    }

    // Then in your main file:
    import "path/to/States.qml" as States

    function getSomething(id: int): string {
    if (id === States.State0) return "This is State0";
    // etc.
    }

    The key point is that in QML, enums are essentially integers under the hood, so you need to use id: int as the parameter type. The enum values themselves can still be used for comparison inside the function.
    Hope this helps!

  • Basic QML object declaration syntax question

    Solved
    4
    0 Votes
    4 Posts
    51 Views
    Tom assoT

    @JonB Oh, that makes total sense! Thanks!

  • QMediaRecorder not record using QVideoFrameInput

    Unsolved
    1
    0 Votes
    1 Posts
    41 Views
    No one has replied
  • Face coloring on custom geometry

    Unsolved
    2
    0 Votes
    2 Posts
    76 Views
    johngodJ

    Hi @OlivierD
    You can use colorsemantic using the addAttribute(....) to define a color for each face , iirc just make sure that in the model Material you set

    lighting: DefaultMaterial.NoLighting
  • Introducing 'Toastify' for QML

    2
    1 Votes
    2 Posts
    97 Views
    aeriqueA

    Hey, thanks for this! I was looking around for something to replace my homegrown toasts with now that my app is getting closer to an alpha release and this is pretty much perfect.

    I did have to comment out parent: Overlay.overlay in Toastify.qml because (I think) my top window in QML is a Rectangle because of the library I am using (LQML).

  • PathView delegate use attached attributes

    Solved
    9
    0 Votes
    9 Posts
    283 Views
    JoeCFDJ

    @Fan__ said in PathView delegate use attached attributes:

    QtVersion: 5.12.5

    QtVersion: 5.12.5 is too old. Upgrade Qt above 5.15 or 6.8.

  • Different rendering of c++ QtLabel and Qml label

    Unsolved
    6
    0 Votes
    6 Posts
    121 Views
    GrecKoG

    The sizeHint of a QQuickWidget is based on the actual size of it's root item and not on its implicit size, I think that explains the discrepancy.

    minimumSizeHint() or minimumSize() are not implemented for QQuickWidget but they are for QLabel.

    You could try inheriting from QQuickWidget and override both sizeHint and minimumSizeHint by returning its root QQuickItem's implicit width/height.

  • Cannot clear selection in GridView/ListView

    Solved
    2
    0 Votes
    2 Posts
    93 Views
    T

    Qt 6 changed some input event handling, so you might need to adjust the event capturing logic.

    So the solution is:

    GridView { id: gridViewNodes anchors.fill: parent cellWidth: 140 cellHeight: 120 clip: true highlightMoveDuration: 100 reuseItems: true // unselect MouseArea { anchors.fill: parent propagateComposedEvents: true onClicked: (mouse) => { gridViewNodes.currentIndex = -1 nodeListMultiSelectionHandler.resetSelection() mouse.accepted = false // allow selection } }
  • 0 Votes
    8 Posts
    662 Views
    H

    The issue was solved Add child model in parent repeater's Compoenet.onCompleted.

    Repeater { id: repeater1 model: backend.graphModel Component.onCompleted: { repeater2.model = model.GraphMaximumCount } } Repeater { id: repeater2 }
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    83 Views
  • 0 Votes
    3 Posts
    3k Views
    Q

    you need to call setFlag(ItemAcceptsInputMethod, true);

  • 0 Votes
    1 Posts
    53 Views
    No one has replied
  • Help with Resizable Columns in TableView

    Unsolved
    3
    0 Votes
    3 Posts
    393 Views
    A

    I think this repository can help you.
    https://github.com/tlaemmlein/TableViewQtQuick2Examples

  • Q_NAMESPACE, Q_ENUM_NS and qmlRegisterUncreatableType

    Solved
    3
    0 Votes
    3 Posts
    123 Views
    DuBuD

    @GrecKo Ah, cool, thank you!

  • qml with QQuickPaintedItem will slow down the ui operation

    Unsolved
    4
    0 Votes
    4 Posts
    140 Views
    Q

    @GrecKo thanks ,i will try video output later, now i use QQuickFramebufferObject.

  • Manage focus between multiple displays on Linux Wayland

    Unsolved
    4
    0 Votes
    4 Posts
    164 Views
    SGaistS

    That's something worth discussing.
    I currently don't know the details of the Wayland protocols and how to leverage them from Qt for your situation.