Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • Connection between asynchronous Loader in a StackLayout ?

    Solved
    3
    0 Votes
    3 Posts
    972 Views
    mbruelM
    @GrecKo Well I didn't implement that code. I don't think a StackView would do it, I've simplified and removed the other Pages but the idea is to have some kind of TabView with all the Pages being loaded only once and never being destructed. I guess this wouldn't work with a StackView. Can a TabView do it? Using Loaders allowed to only load the Pages when they are first used, not all at the loading of the ApplicationWindow. Does this make sense? The plantingsPage is a ListView. It allows to modify its Elements. When this happens I need to warn the locationsPage as it is presenting some of those Elements in another manner (TreeView). The current implementation is not ideal and rely directly on models deriving from QSqlTableModel. Before rethinking the architecture, I would just need to connect to a signal from plantingsPage in my StackLayout or ApplicationWindow so I could call a function on locationsPage. Isn't this possible? The parameter would be an array of int so just a var no? I've done something that seems to work. Could you please let me know what you think and if there are better QML practice. MainWindow.qml: ApplicationWindow { id: window function plantingsRefreshed(plantingsIdList){ print("MainWindow plantingsRefreshed: " + plantingsIdList); if (locationsPage.item) locationsPage.item.reloadLocationView(plantingsIdList); } ... same definition of the property navigationModel and the StackLayout defined in my first post... } PlantingsPage.qml Page { id: page title: qsTr("Plantings") signal plantingsRefreshed(var plantingsIdList) // array of int Component.onCompleted: { page.plantingsRefreshed.connect(window.plantingsRefreshed); } } LocationsPage.qml Page { id: page function reloadLocationView(plantingsIdList) { print("reloadLocationView: " + plantingsIdList); } ... }
  • Camera Preview Full Screen

    Unsolved
    2
    0 Votes
    2 Posts
    521 Views
    MarkkyboyM
    @NullByte said in Camera Preview Full Screen: VideoOutput Have you tried different types of fillMode ? fillMode : enumeration Set this property to define how the video is scaled to fit the target area. Stretch - the video is scaled to fit. PreserveAspectFit - the video is scaled uniformly to fit without cropping PreserveAspectCrop - the video is scaled uniformly to fill, cropping if necessary The default fill mode is PreserveAspectFit. https://doc.qt.io/qt-5/qml-qtmultimedia-videooutput.html#fillMode-prop
  • [SOLVED] How to get to work c++ qml extension.

    3
    0 Votes
    3 Posts
    8k Views
    N
    Any luck with this @misterion ?? Working ferociously on adding my own plugin to a project but have yet to come to a solution..
  • use qml treeview in pyside 6 or similar

    Solved
    12
    0 Votes
    12 Posts
    2k Views
    Q
    hi guys, i'm back again (;. after a few hours i made a simple treeview that you can use it: TreeView Class Code: import QtQuick 2.0 import QtQuick.Controls 2.5 Item { id: root // ************* UNDER LIST ************* property var underModel: ListModel { Component.onCompleted: { for(var i = 0; i < 20; i++) { append( { text: "C:/Qt/Examples/" + i } ) } } } // ************* MAIN LIST ************* property var mainModel: ListModel { Component.onCompleted: { for(var i = 0; i < 10; i++) { append( { text: "C:/Qt/Examples/Qt-6.2.2/core5/widgets/tools/codecs/doc/images " + i } ) } } } ListView { id: mainLV anchors.fill: parent spacing: 1 model: root.mainModel delegate: ItemDelegate { width: root.width height: 20 // ************************** UNDER LIST ************************** ListView { id: lvUnder2 height: count * 21 anchors.left: parent.left anchors.leftMargin: 20 anchors.right: parent.right spacing: 1 y: 0 model: root.underModel visible: false z: 20 delegate: ItemDelegate { width: root.width height: 20 Rectangle { height: 21 width: 1.5 color: "black" } background: Rectangle { id: rctUnderLVBG2 color: "white" } contentItem: Item { anchors.fill: parent Rectangle { width: 15 height: 1 anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter color: "black" } Label { anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter transform: Translate {y: -1} anchors.leftMargin: 18 text: model.text } } } } // ************************** UNDER LIST ************************** background: Rectangle { id: rctMainLVBG color: "white" } contentItem: Item { anchors.fill: parent MouseArea { anchors.fill: parent onClicked: { if(imgOpenList.source== "open image here") { imgOpenList.source= "close image here" lvUnder2.visible= false mainLV.itemAtIndex(index).height= 20 } else { imgOpenList.source= "enter open image here" lvUnder2.y= 21 mainLV.itemAtIndex(index).height= lvUnder2.height + 21 lvUnder2.visible= true } } } Label { id: lblAddress anchors.left: imgOpenList.left anchors.verticalCenter: parent.verticalCenter anchors.top: parent.top anchors.leftMargin: 14 text: model.text } Image { id: imgOpenList source: "enter open image here" width: 11 height: 11 anchors.left: parent.left anchors.top: parent.top anchors.topMargin: 1 anchors.leftMargin: 2 } } } } } main: import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.5 Window { width: 640 height: 480 visible: true title: qsTr("Hello World") TreeView { id: mine anchors.fill: parent } } it's not completed but is enough to expand; ♥
  • QtCreator use caches and doesnt recompile QML

    Unsolved qml qtcreator
    1
    0 Votes
    1 Posts
    257 Views
    No one has replied
  • Exposing struct members to QML from derived QQuickItem-class

    Unsolved
    2
    0 Votes
    2 Posts
    313 Views
    M
    @adaptine said in Exposing struct members to QML from derived QQuickItem-class: 我有一个从 QQuickItem 派生的类,其中包含重载的 updatePaintNode ...... 该类被注册为qmlRegisterType<DPShip>("dpship", 1, 0, "DPShip"); 这很好用。 我想为我的班级在 QML 中拥有border.width和border.color属性。 所以在 DPShip.h 我试过: Hi I also want to know that qgss series draws borders. Can I see your source code? thank you
  • How to use QSGGeometriynodes to draw the border of a graph?

    Unsolved
    1
    0 Votes
    1 Posts
    124 Views
    No one has replied
  • 0 Votes
    5 Posts
    896 Views
    Q
    @JonB so what i should to do? ):
  • Error code (m129)

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    KroMignonK
    @stm32learn said in Error code (m129): Just rename my new object to other name I don't understand what you are saying? Do you mean the QML filename? Is it called Button.qml ? If this was the issue, you could also just use full name in QML to avoid name conflicts: import QtQuick 2.15 import QtQuick.Controls 2.12 QtQuick.Controls.Button { }
  • Cannot find EGLConfig, returning null config

    Unsolved
    1
    0 Votes
    1 Posts
    955 Views
    No one has replied
  • flickableItem.atYEnd is false even at the bottom of scroll

    Unsolved
    1
    0 Votes
    1 Posts
    168 Views
    No one has replied
  • Two way property binding in QML

    Unsolved
    2
    0 Votes
    2 Posts
    2k Views
    fcarneyF
    Its NOT bidirectional. There are ways to bind to the values from other objects and C++, but it is about as messy as doing it from the on<value>Changed signal. https://doc.qt.io/qt-5/qtqml-syntax-propertybinding.html https://doc.qt.io/qt-5/qml-qtqml-binding.html
  • Implementing an action class in C++ for a QML app

    Solved
    10
    0 Votes
    10 Posts
    1k Views
    raven-worxR
    @iwoithe your QMLAction.qml can actually just be: import QtQuick 2.15 import QtQuick.Controls 2.15 Action { id: action } And when you create a button: Button { anchors.centerIn: parent //text: qsTr("Print Hello") //might also be taken from action action: ActionController.getActionFromName("hello") } Then from C++ you can do on the action instance: Call method: QMetaObject::invokeMethod(actionObj, "trigger", Qt::AutoConnection); // call method or QMetaObject::invokeMethod(actionObj, "trigger", Qt::AutoConnection, Q_ARG(QObject*,this)); Read/Write property: QVariant val = QQmlProperty ::read(actionObj, "text"): QQmlProperty ::write(actionObj, "enabled", QVariant::fromValue<bool>(false)):
  • New TreeView in Qt6

    Unsolved
    1
    1 Votes
    1 Posts
    217 Views
    No one has replied
  • 0 Votes
    1 Posts
    172 Views
    No one has replied
  • ApplicationWindow is not visible by default?

    Unsolved
    2
    0 Votes
    2 Posts
    198 Views
    SGaistS
    Hi, Good point ! A fix for the doc has been submitted.
  • Qml inspection, eventFilter

    Unsolved qml c++
    2
    1 Votes
    2 Posts
    321 Views
    KH-219DesignK
    I'll check back tomorrow or Tuesday to see if I can better explain the code that I am about to share. I'm in a hurry today, so I'm just going to paste this and hope that anyone reading it can make use of it :) #include <QQmlComponent> #include <QQmlProperty> #include <QQuickItem> void dumpRecursive( int level, QObject* object ) { if( object ) { QByteArray buf; buf.fill( ' ', level / 2 * 8 ); if( level % 2 ) buf += " "; QString name = object->objectName(); QVariant propv = QQmlProperty::read( object, "visible" ); if( propv.isNull() ) { fprintf( stderr, "%s\n", "IS_NULL visible prop" ); } else { QQmlProperty prop( object, "visible" ); fprintf( stderr, "hasNotifySignal %d\n", static_cast<int>( prop.hasNotifySignal() ) ); fprintf( stderr, "isResettable %d\n", static_cast<int>( prop.isResettable() ) ); fprintf( stderr, "isSignalProperty %d\n", static_cast<int>( prop.isSignalProperty() ) ); fprintf( stderr, "isValid %d\n", static_cast<int>( prop.isValid() ) ); fprintf( stderr, "isWritable %d\n", static_cast<int>( prop.isWritable() ) ); fprintf( stderr, "propertyTypeName %s\n", prop.propertyTypeName() ); fprintf( stderr, "needsNotifySignal %d\n", static_cast<int>( prop.needsNotifySignal() ) ); // bool QQmlProperty::needsNotifySignal() const // QMetaMethod m = prop.method(); } QVariant prop = QQmlProperty::read( object, "testtest" ); if( !prop.isNull() ) { if( !prop.canConvert<QList<QVariant>>() ) { fprintf( stderr, "%s\n", "whoooooooooooooooooooooooooops ! ! !" ); } else { QList<QVariant> list = prop.toList(); fprintf( stderr, "wheeeeeeeeeeeeeeeee %p\n", reinterpret_cast<void*>( &list ) ); for( const auto& state : list ) { fprintf( stderr, "got one %p\n", reinterpret_cast<void*>( &list ) ); if( state.canConvert<QQuickItem*>() ) { QQuickItem* t = state.value<QQuickItem*>(); fprintf( stderr, "converts one %p\n", reinterpret_cast<void*>( t ) ); } } } } qDebug( "%s%s::%s", reinterpret_cast<const char*>( buf.data() ), object->metaObject()->className(), name.toLocal8Bit().data() ); QObjectList children = object->children(); if( !children.isEmpty() ) { for( int i = 0; i < children.size(); ++i ) dumpRecursive( level + 1, children.at( i ) ); } } } void localDump( QObject* object ) { dumpRecursive( 0, object ); } // return true if the event should be filtered (i.e. stopped) bool EventFilter::eventFilter( QObject* obj, QEvent* event ) { localDump( obj ); return QObject::eventFilter( obj, event ); }
  • 0 Votes
    9 Posts
    386 Views
    C
    @GrecKo Could you elaborate on how to use qRegisterMetaType? And on what you mean by root context properties should not be used anymore, access lookup is heavy for them.
  • qml app does not run without any error and but does run in <qtVersion>\mingw\bin

    Solved
    5
    0 Votes
    5 Posts
    604 Views
    Q
    @SGaist it worked fine. thank you so much (: ❤️
  • QML Svg in qt 5.15 static build, using CMake

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    B
    The solution for me was in addition to including Qt5::Svg in find_package and target_link_libraries, eg: find_package(Qt5 REQUIRED COMPONENTS Core Quick Qml Xml Charts Gui Svg QuickControls2) target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick Qt5::Qml Qt5::Xml Qt5::Charts Qt5::Gui Qt5::Svg Qt5::QuickControls2) To also include the following when statically linking Qt 5.15: qt5_import_plugins(${PROJECT_NAME} INCLUDE Qt5::QSvgPlugin) That resolved errors such as "QML ButtonIcon: Error decoding: qrc:/resources/images/add-white-36dp.svg: Unsupported image format"