Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • How to cause exact cycle like Thread to occur in QML?

    Unsolved
    1
    0 Votes
    1 Posts
    148 Views
    No one has replied
  • Passing data between QML. A QML <-> B QML

    Unsolved
    7
    0 Votes
    7 Posts
    482 Views
    I
    @fcarney thank you I will study hard.
  • How to display a QWindow in the way as a QQuickItem?

    Unsolved
    1
    0 Votes
    1 Posts
    210 Views
    No one has replied
  • Autocompletion Not Working in QML for C++ Instances

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    R
    @GrecKo said in Autocompletion Not Working in QML for C++ Instances: Don't use setContextProperty to expose your C++ instances. https://doc.qt.io/qt-6/qtqml-cppintegration-overview.html#choosing-the-correct-integration-method-between-c-and-qml Okay. Thank you. I've been through those several times and am still rereading and rereading them trying to get a complete understanding of them. I notice they use a pro file to add the components so I'll have to convert that to cmake terms. I'm new to using Qt6 and the last time I used Qt5 was a few years ago so a lot has changed mainly the use of cmake instead of a pro file which is fine with me and I want to learn to use the cmake build process. I've been trying to find the "right way" to do this but there seems to be a lot of conflicting posts out there and unfortunately I think many still fall back on the Qt5 processes which may work but don't help someone trying to find the Qt6 way! I use the QObject and QML_ELEMENT and QML_PROPERTY in my classes as well as including the qml registration header. So any help is appreciated. I have a CMakeLists.txt in my project main which adds a subdirectory for utils in which I have a CMakeLists.txt that creates a static library and adds a qml module which is then linked in the main CMakeList.txt All of this is based on the blog post for Qt6 about the new modules . I assume I still need to include the Q_IMPORT_QML_PLUGIN(utilsPl,ugin) in main.cpp. Is this correct? Then if I am correct I can use the import utils (the module URI) in my QML modules? The Qt documentation is much better then most for sure but sometimes I feel since they know the process they use partial examples and leave out what is obvious to them. I'd love a blog on how to create a project from scratch with subdirectories, adding the libraries, and then integrating a sample C++ property and function into QML and include all the steps to do setup in main.cpp and any QML modules and of course a sample going the other way!f utils/CMakeLists.txt # CMakeLists.txt to build import backend. qt_add_library(utils_module STATIC) qt6_add_qml_module(utils_module URI utils VERSION 1.0 SOURCES utils.h utils.cpp ) Main CMakeLists.txt cmake_minimum_required(VERSION 3.16) project(FlightLog VERSION 0.1 LANGUAGES CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Set application name for use in building. set(appName "FlightLogbook") #find_package(Qt6 COMPONENTS Quick REQUIRED) # Core is probably redundant due to Quick find find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick Sql ) # Standard project setup #qt_standard_project_setup() # The executable qt_add_executable(FlightLogbook main.cpp ) #============================================================================== # Our subdirectories add_subdirectory( importdata ) add_subdirectory( fldbase ) add_subdirectory( utils ) #============================================================================== # QML and other files qt_add_qml_module(FlightLogbook URI FlightLog VERSION 1.0 QML_FILES main.qml Initapp.qml ) set_target_properties(FlightLogbook PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) # Added Core, Qml as private libraries target_link_libraries(FlightLogbook PRIVATE Qt6::Core PRIVATE Qt6::Quick PRIVATE Qt6::Qml PRIVATE Qt6::Sql ) #============================================================================== # Our libraries target_link_libraries( FlightLogbook PRIVATE import_moduleplugin PRIVATE fldbase_moduleplugin PRIVATE utils_moduleplugin ) # Attempting to put the runtime result in the directory above the build install(TARGETS FlightLogbook BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION .. )
  • How to paint a polygon and image in qml rectangle

    Solved
    4
    0 Votes
    4 Posts
    322 Views
    JoeCFDJ
    @fcarney Thanks for the info. I think that Qt 6 book has Shapes chapter. I will have peek at it. Great work!
  • Tests crash when using C++ Singletons

    Solved
    4
    0 Votes
    4 Posts
    461 Views
    GrecKoG
    @PavloPonomarov said in Tests crash when using C++ Singletons: When registered, singleton always logs that it has CppOwnership: Which means QQmlEngine::setObjectOwnership(instance, QQmlEngine::CppOwnership); will do nothing in my case. Not really, CppOwnership is also returned for objects with no explicit ownership. If you were to set it explicitely, it won't be overwritten later by the engine.
  • RowLayout: align one item at right

    Solved
    3
    0 Votes
    3 Posts
    2k Views
    M
    You can try to put some kind of spacing item in between the Button and the Rectangle which fills the remaining width, instead of using Layout.alignment. [...] Button { Layout.preferredWidth: 32 Layout.preferredHeight: 28 text: "..." onClicked: fileDialog.open() enabled: !scriptingViewModel.isRunning } Item { // spacer Layout.fillHeight: true Layout.fillWidth: true } Rectangle { Layout.preferredWidth: 60 Layout.preferredHeight: 28 //Layout.alignment: Qt.AlignRight Layout.rightMargin: 40 color: "red" } I do normally use an opposite Layout for such purposes, as they fill height and width by default.
  • Android APP GUI freeze sometime

    Unsolved
    1
    0 Votes
    1 Posts
    150 Views
    No one has replied
  • How to Align text centre in tab button?

    Moved Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    J.HilkJ
    @JonB agreed, so moved. @Shankar-B you can customise it like any other Button element: https://doc.qt.io/qt-6/qtquickcontrols2-customize.html#customizing-button TabButton{ id: control text: qsTr("TabButton") contentItem: Text { text: control.text font: control.font opacity: enabled ? 1.0 : 0.3 color: control.down ? "#17a81a" : "#21be2b" horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } }
  • How to obtain winId of qml Window?

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    fcarneyF
    You should provide code as to how and when you are creating this window that you need the id from. QML Window is C++ type QQuickWindow which is of type QWindow.
  • QML ChartView: custom draw graph

    Unsolved qml qchartview qt5.15.2
    1
    0 Votes
    1 Posts
    290 Views
    No one has replied
  • Popup as extern Window?

    Unsolved
    3
    0 Votes
    3 Posts
    295 Views
    JKSHJ
    @freedbrt said in Popup as extern Window?: Is there are any way to open popup as Window like it was before in QuickControls 1.0 ? Not as of Qt 6.4, unfortunately. It is a known issue: https://bugreports.qt.io/browse/QTBUG-69558 The issue has been around for a long time, but is still on the radar for the Qt engineers (see the "Future Work" section of https://www.qt.io/blog/dialogs-in-qt-quick )
  • ScrollView interfering with MouseArea and/or MouseEvents

    Solved
    8
    0 Votes
    8 Posts
    5k Views
    A
    Hello, i found a small solution for the mouse wheel problem by using a timer ScrollView { anchors { fill: parent } Component.onCompleted: contentItem.interactive = false background: Rectangle { id: scrollViewbackgroundRect anchors.fill: parent color: "transparent" MouseArea { anchors.fill: parent property var mytimer : new Timer(scrollViewbackgroundRect); onClicked: { console.log("background clicked"); } onWheel: { console.log("enabling interactive") scrollViewTours.contentItem.interactive = true mytimer.interval = 500; mytimer.repeat = false; mytimer.triggered.connect(function () { console.log("disabling interactive") scrollViewTours.contentItem.interactive = false }) mytimer.start(); } } } } the JS function function Timer(parent) { return Qt.createQmlObject("import QtQuick 2.0; Timer {}", parent); }
  • QML element resize cause flicker on MacOS

    Unsolved resize macos flicker
    1
    0 Votes
    1 Posts
    447 Views
    No one has replied
  • 0 Votes
    4 Posts
    3k Views
    M
    Hello, I had the same problem with showing the list of cameras in a ComboBox. the correct code is: ComboBox { id: cmbVideoCaptures model: QtMultimedia.availableCameras textRole: "displayName" valueRole: "deviceId" }
  • Shrink/resize item

    Solved
    2
    0 Votes
    2 Posts
    249 Views
    Q
    It's "scaling" guys.
  • Controls.Button do not underline accelerator key

    Unsolved
    3
    0 Votes
    3 Posts
    271 Views
    A
    @JoeCFD said in Controls.Button do not underline accelerator key: Which OS? And Qt version? Operating System: Manjaro Linux KDE Plasma Version: 5.25.5 KDE Frameworks Version: 5.97.0 Qt Version: 5.15.5 Kernel Version: 5.15.65-1-MANJARO (64-bit) Graphics Platform: X11 Processors: 20 × 12th Gen Intel® Core™ i9-12900H Memory: 15,4 GiB of RAM Graphics Processor: Mesa Intel® Graphics Manufacturer: HUAWEI Product Name: CREF-XX System Version: M1010
  • QML Chart Y-axis padding

    Unsolved
    2
    0 Votes
    2 Posts
    541 Views
    thomas.denicoloT
    UP! Has anyone managed to solve this problem?
  • Block Virtual keyboard popup for a particular TextField/TextArea in QML

    Unsolved
    1
    0 Votes
    1 Posts
    191 Views
    No one has replied
  • How to develop for more than one style

    Unsolved
    1
    0 Votes
    1 Posts
    114 Views
    No one has replied