Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.3k Topics 78.3k Posts
Qt 6.11 is out! See what's new in the release blog
  • We're looking for developers to interview about their migration experience

    Pinned until 31/08/2026, 14:23 Unsolved
    7
    2 Votes
    7 Posts
    277 Views
    SGaistS
    @A-Former-User said in We're looking for developers to interview about their migration experience: @KH-219Design: similar here, some explanation who is "we" or at least a qt.io link may help. Anyway: Why the interest in porting "within" Qt, not "to" Qt? And if "within", why not target the smaller and faster solution? Because the question was: from widgets to Qt Quick whatever the size of the application.
  • How to clear TextEdit's textDocument.source?

    Unsolved
    8
    0 Votes
    8 Posts
    221 Views
    D
    @jayrickaby Regarding textDocument.source reset in QT Quick: I can see you're frustrated — this is a genuinely tricky QQuickTextDocument limitation! The short answer: You cannot directly "unset" textDocument.source once it's been set via QML/JS. Qt doesn't expose a clean reset method for it. The real solution — handle it from Python backend: pythonfrom PySide6.QtCore import QObject, Slot, Signal class Backend(QObject): fileCleared = Signal() requestSaveAs = Signal() def __init__(self): super().__init__() self.current_path = None # None = unsaved new file @Slot() def new_file(self): self.current_path = None self.fileCleared.emit() # Tell QML to clear the text @Slot(str) def save_file(self, text): if self.current_path is None: self.requestSaveAs.emit() else: with open(self.current_path, 'w') as f: f.write(text) @Slot(str) def open_file(self, path): self.current_path = path qmlTextEdit { id: textEdit } Connections { target: backend function onFileCleared() { textEdit.clear() // Don't touch textDocument.source at all } } Why your attempts failed: source = "" — Qt tries to resolve empty string as a URL, document loses context source = undefined — QUrl binding is strict, doesn't accept undefined new URL() — wrong argument count for QUrl constructor textEdit.clear() — works but leaves source stale (which is fine!) The key insight: textDocument.source is only meant for loading files. For a "New File" action, just track the file path in Python as None, call textEdit.clear() in QML, and never touch textDocument.source until the user actually opens or saves a real file. The stale source does not affect editing at all. Edit: removed spam content
  • 0 Votes
    4 Posts
    91 Views
    J
    Thanks Christian — that lines up. I checked the qt/qtbase 6.11 branch and the fix is right there in QDockWidgetGroupWindow::reparentToMainWindow() (src/widgets/widgets/qmainwindowlayout.cpp): an early mwLayout->savedState.clear();, with a comment that nails the cause: mwLayout->widgetAnimator.abort(dockWidget); // The saved state is now invalid because it contains // a reference to the dock widget inside the group window. // - the dock widget has been reparented. // - if it was the last dock widget, the group window will be deleted // => clear saved state. mwLayout->savedState.clear(); That matches the root cause exactly: the drag's savedState snapshot shares QLayoutItem* with layoutState, reparentToMainWindow() invalidates them, and the nested setFloating() → endDrag() → restore() replays the stale snapshot in reparentWidgets() → the AV. (Reassuring to land on the same one-liner independently.) So for anyone hitting this on 6.11.1 before 6.11.2 ships: the one-line backport above in reparentToMainWindow() fixes it — verified on Windows 11 / Qt 6.11.1 / MSVC x64 (2→1 tear no longer crashes; create/move and the 3→2 tear are unaffected). And once on 6.11.2 / 6.12 the official fix covers it, so the local patch can just be dropped. Thanks again for the quick pointer!
  • Get QtGraphs with XYModelMapper working

    Unsolved
    15
    0 Votes
    15 Posts
    866 Views
    JoeCFDJ
    @Bob64 You are right. I did not pay attention to it.
  • A Simple Question About Icons Of Window

    Solved
    3
    0 Votes
    3 Posts
    90 Views
    K
    @jsulm said in A Simple Question About Icons Of Window: @Kansas said in A Simple Question About Icons Of Window: But I think ApplicationWindow does have the property "icon" right? Wrong. See https://doc.qt.io/qt-6/qml-qtquick-controls-applicationwindow.html What icons do you mean? The icons in the title bar of the window (close/minimize/maximize)? Oh, I see. Thanks a lot. I specifically mean the icons in the title bar of the window, but I also want to set the icon of the exe. I'll search it again carefully. Thank you again.
  • QT QML Android Edge-to-Edge (notch screen) setup

    Unsolved
    1
    0 Votes
    1 Posts
    75 Views
    No one has replied
  • How can I be GOAT in QML ?

    5
    0 Votes
    5 Posts
    314 Views
    S
    I guess it depends on your learning style. How did you learn QWidgets? Do you prefer to read or watch videos. Depending on how well you know other parts of Qt already and how comfortable you feel, you can also just learn from the documentation (that's where I would start). The knowledge there is quite condensed, but should have all the important facts. Sure, it does not necessarily give you experience. Also, the examples should be helpful to get a feel for QML. Learning from the documentation should be the fastest if it suits your learning style and current level of understanding of programming. PS: I personally haven't used QML, yet.
  • 0 Votes
    1 Posts
    114 Views
    No one has replied
  • Tumbler doesn't respond on mouse wheel

    Solved
    3
    1 Votes
    3 Posts
    321 Views
    M
    @Markkyboy Explicitly adding WheelHandler helped. Thank you!
  • No QML error when property missing from Q_GADGET

    Solved
    2
    0 Votes
    2 Posts
    144 Views
    GrecKoG
    gadget.nonExistentProperty will evaluate to undefined so that's not a runtime error or warning. I believe qmllint would flag this though.
  • How to pass `QQuickWheelEvent` to C++?

    Solved
    5
    0 Votes
    5 Posts
    558 Views
    jeremy_kJ
    Hopefully, this will seem obvious in retrospect. Event objects in QML must logically either be special-cased by the engine, or QObject instances with properties accessed via the normal mechanism. A look at some source code suggests the later. As such, event instances can be passed to functions that receive a QObject *. Properties of the object can then be read via QObject::property() or QMetaObject::property().
  • Repeater and Delegate: ctx.fillStyle does not update color on DataChanged

    Solved
    5
    0 Votes
    5 Posts
    337 Views
    I
    @GrecKo I also added some text to the circle.
  • Problem with DoubleSpinBox in TableView

    Unsolved qml tableview doublespinbox
    1
    0 Votes
    1 Posts
    163 Views
    No one has replied
  • QML Profiler Debug connection failed

    Unsolved
    1
    0 Votes
    1 Posts
    150 Views
    No one has replied
  • An Unknown Segfault

    Solved
    7
    0 Votes
    7 Posts
    875 Views
    A
    Post is updated. Upgrade to Qt 6.11.1 probably did the magic
  • Instanting Q_GADGET

    Unsolved qtquick c++
    3
    0 Votes
    3 Posts
    3k Views
    D
    C++: class MyValueType { Q_GADGET QML_VALUE_TYPE(myValueType) QML_CONSTRUCTIBLE_VALUE public: Q_INVOKABLE MyValueType(double d = 0.0); // ... }; QML: import MyModule as MM QtObject { function process(d: real) { let v = new MM.myValueType(d); // v is a myValueType now } }
  • Create un MapRectangle crossing the antimeridian

    Unsolved
    1
    1 Votes
    1 Posts
    168 Views
    No one has replied
  • MapQuickItem + MapboxGl ignores item stack ordering

    Unsolved
    1
    0 Votes
    1 Posts
    180 Views
    No one has replied
  • Android Keyboard AdjustPan gap between kbd and TextEdit

    Unsolved
    1
    0 Votes
    1 Posts
    168 Views
    No one has replied
  • QQmlEngine::setExternalSingletonInstance

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