跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.4k 貼文
  • SwipeView with GridView

    Solved
    2
    0 評價
    2 貼文
    225 瀏覽
    C
    Ah I think I understand now. It would seem that using predefined properties is not okay and I was wrong about how the GridView was anchoring itself. Something like this works: ListModel { id: theModel ListElement { name: "red" breadth: 75 ceiling: 120 } ListElement { name: "blue" breadth: 100 ceiling: 120 } ListElement { name: "green" breadth: 200 ceiling: 120 } } SwipeView { id: view currentIndex: 1 anchors.fill: parent GridView { width: 300; height: 200 anchors.fill: parent model: theModel delegate: Rectangle { width: breadth height: ceiling color: name } } }
  • Connection between asynchronous Loader in a StackLayout ?

    Solved
    3
    0 評價
    3 貼文
    977 瀏覽
    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 評價
    2 貼文
    521 瀏覽
    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 評價
    3 貼文
    8k 瀏覽
    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 評價
    12 貼文
    2k 瀏覽
    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 評價
    1 貼文
    257 瀏覽
    尚無回覆
  • Exposing struct members to QML from derived QQuickItem-class

    Unsolved
    2
    0 評價
    2 貼文
    313 瀏覽
    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 評價
    1 貼文
    124 瀏覽
    尚無回覆
  • problem with ColorDialog : plugin cannot be loaded for module "Qt.labs.platform" using qml

    Solved
    5
    0 評價
    5 貼文
    898 瀏覽
    Q
    @JonB so what i should to do? ):
  • Error code (m129)

    Solved
    7
    0 評價
    7 貼文
    1k 瀏覽
    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 評價
    1 貼文
    961 瀏覽
    尚無回覆
  • flickableItem.atYEnd is false even at the bottom of scroll

    Unsolved
    1
    0 評價
    1 貼文
    168 瀏覽
    尚無回覆
  • Two way property binding in QML

    Unsolved
    2
    0 評價
    2 貼文
    2k 瀏覽
    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 評價
    10 貼文
    1k 瀏覽
    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 評價
    1 貼文
    217 瀏覽
    尚無回覆
  • Is there a way to change the mouse cursor shape when hover over SplitView handle? (Qt 5.15.2)

    Unsolved
    1
    0 評價
    1 貼文
    172 瀏覽
    尚無回覆
  • ApplicationWindow is not visible by default?

    Unsolved
    2
    0 評價
    2 貼文
    198 瀏覽
    SGaistS
    Hi, Good point ! A fix for the doc has been submitted.
  • Qml inspection, eventFilter

    Unsolved qml c++
    2
    1 評價
    2 貼文
    322 瀏覽
    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 評價
    9 貼文
    387 瀏覽
    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 評價
    5 貼文
    610 瀏覽
    Q
    @SGaist it worked fine. thank you so much (: ❤️