Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • [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"
  • Make Independent Popup

    Solved
    4
    0 Votes
    4 Posts
    408 Views
    PadawanP
    @GrecKo Thanks I've gotten it sorted out. I encapsulated the component i wanted to show inside a window and created it using Qt.createComponent() var playListComponent = Qt.createComponent("CustomPlaylist.qml") var window = playListComponent.createObject(rootWindow) window.show() The root element of CustomPlaylist.qml is a Window [image: 4c1cfe8b-9403-4008-9066-c4ec97b8f368.png]
  • why doesn't it draw PathLine ??

    Unsolved quick qt quick qt5.11
    2
    0 Votes
    2 Posts
    823 Views
    B
    If I understood correctly, you want to draw a red line. The purpose of Path is to position elements through a path. Think of a row or a column that's not straight. You can understand better if you run the first example from this tutorial. To draw paths you need Shape. import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Shapes 1.12 Window { width: 640 height: 480 visible: true title: qsTr("Редактор персонажей") Shape { ShapePath { strokeColor: "red"; // it works :) startX: 0; startY: 100 PathLine { x: 640; y: 480 } } } }