跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k 主題 77.7k 貼文
  • Howto expose ID of an element in an item ?

    Unsolved
    3
    0 評價
    3 貼文
    341 瀏覽
    J.HilkJ
    @pingal I have the feeling I answered this recently.... ah right: https://forum.qt.io/topic/133544/hot-to-reference-to-the-bordercolor
  • hot to reference to the bordercolor?

    Unsolved
    3
    0 評價
    3 貼文
    400 瀏覽
    L
    @daka said in hot to reference to the bordercolor?: validateTextField(id, idError, borderColor) { id.style.TextFieldStyle.background.border.color = "red" } First of all you could do it automatically by property binding, as the TextField has a property "acceptableInput": TextField { id: firstname Layout.minimumWidth: 300 placeholderText: qsTr("type here your firstname") activeFocusOnPress: true background: Rectangle { radius: 5 border.color: firstname.acceptableInput ? "green" : "red" border.width: 1 } validator: RegExpValidator { regExp: /[A-Z a-z 0-9]+/ } } In case you want to stick to the validation function, you could do it e.g. like this: TextField { id: firstname Layout.minimumWidth: 300 placeholderText: qsTr("type here your firstname") activeFocusOnPress: true background: Rectangle { radius: 5 border.color: "gray" border.width: 1 } validator: RegExpValidator { regExp: /[A-Z a-z 0-9]+/ } // pass the current element and validation // (validation could be addressed from the passed element as well) onFocusChanged: validateTextField(this, acceptableInput) } /* validation function */ function validateTextField(el, valid) { el.background.border.color = valid ? "green" : "red" }
  • Howto show button as Active/InActive on click in QML

    5
    0 評價
    5 貼文
    1k 瀏覽
    L
    Row { spacing: 40 Button { id: button1 // change text based on enabled property text: enabled ? "Enabled" : "Disabled" background: Rectangle { color: enabled ? "green" : "lightgray" // animate the color change Behavior on color { PropertyAnimation { target: parent duration: 380 } } } onClicked: { // disable the button by setting enabled property to false // onClicked event won't trigger as long as enabled = false enabled = false console.debug("button1 clicked and disabled") } } Button { id: button2 text: "Re-enable button" background: Rectangle{ color: enabled ? "blue" : "lightgray" } enabled: !button1.enabled onClicked: { button1.enabled = true console.debug("button2 clicked and button1 re-enabled") } } }
  • LinearGradient 5.15 WHERE is the start and end property and PLEASE provide a useful example!

    Unsolved
    4
    0 評價
    4 貼文
    350 瀏覽
    L
    Here a simple example: Button { id: myButton height: 150 width: 300 anchors.centerIn: parent text: "MyButton" onClicked: console.debug("myButton was clicked!") background: LinearGradient { id: myGradient anchors.fill: parent property string color: "blue" property double factor: 2.5 // start at (x/y) = (0/0) [top left corner] // as coordinate system INSIDE THIS element start: Qt.point(0, 0) // end at (x/y) = (width/height) [bottom right corner] end: Qt.point(width, height) gradient: Gradient{ // begin with lighter color (brightened by myGradient.factor) GradientStop { position: 0.0 color: Qt.lighter(myGradient.color, myGradient.factor) } // end with darker color GradientStop { position: 1.0 color: myGradient.color } } } }
  • Is there a way to increase the memory size of my QT Quick app

    Unsolved
    2
    0 評價
    2 貼文
    288 瀏覽
    jsulmJ
    @AI_Messiah said in Is there a way to increase the memory size of my QT Quick app: How can I allocate more memory? Your application gets as much memory as it asks for and as much as the OS can handle and as much as can be provided to your app considering RAM size and swap. It sounds like your app consumes too much memory. You should explain what it does and how. Do you load a huge amount of images at the same time? If so why?
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    2 瀏覽
    尚無回覆
  • ShaderEffect on layer create weird artifacts on text

    Unsolved
    2
    0 評價
    2 貼文
    303 瀏覽
    E
    I tested it on both Intel & Nvidia GPUs and I can see the issue on both hardware. What's weird is it that it looks like the kind of issues that would happen when something is wrong in the premultiplied alpha but the documentation says that the input texture is already premultiplied and the output FBO should be premultiplied. So by directly passing the input to the output it should work out okay.
  • How to resize the GroupBox to fit exactly to the width and height of radio buttons in qml

    Unsolved
    3
    0 評價
    3 貼文
    968 瀏覽
    P
    @raven-worx Thank you for the inputs. I am trying to implement the radio buttons based on the size of the parent window. But, the text beside radio buttons are not aligning vertically center. Could you please help me where am doing wrong Window { id: mainwindow visible: true width: 640 height: 480 title: qsTr("Hello World") function getActualValue( percent , value) { var percentageValue = Math.round((percent*value)/100); return percentageValue; } GroupBox { id: groupboxId title: qsTr("Log Meas") font.pixelSize: mainwindow.getActualValue(2, mainwindow.width) width: mainwindow.width/4 height: mainwindow.height/8 anchors.centerIn: parent RowLayout { RadioButton { id: radioButton1 checked: true font.pixelSize: mainwindow.getActualValue(2, mainwindow.width) text: qsTr("Imperial") indicator: Rectangle { implicitWidth: mainwindow.getActualValue(3, mainwindow.height) implicitHeight: mainwindow.getActualValue(3, mainwindow.height) radius: 9 border.color: radioButton1.activeFocus ? "red" : "gray" border.width: 1 Rectangle { anchors.fill: parent visible: radioButton1.checked color: "#555" radius: 9 anchors.margins: 4 } } contentItem: Text { text: radioButton1.text font: radioButton1.font opacity: enabled ? 1.0 : 0.3 color: radioButton1.down ? "#17a81a" : "#21be2b" verticalAlignment: Text.AlignVCenter leftPadding: radioButton1.indicator.width + radioButton1.spacing } } RadioButton { id: radioButton2 checked: false font.pixelSize: mainwindow.getActualValue(2, mainwindow.width) text: qsTr("Metric") indicator: Rectangle { implicitWidth: mainwindow.getActualValue(3, mainwindow.height) implicitHeight: mainwindow.getActualValue(3, mainwindow.height) radius: 9 border.color: radioButton2.activeFocus ? "darkblue" : "gray" border.width: 1 Rectangle { anchors.fill: parent visible: radioButton2.checked color: "#555" radius: 9 anchors.margins: 4 } } contentItem: Text { text: radioButton2.text font: radioButton2.font opacity: enabled ? 1.0 : 0.3 color: radioButton2.down ? "#17a81a" : "#21be2b" verticalAlignment: Text.AlignVCenter leftPadding: radioButton2.indicator.width + radioButton2.spacing } } } } } The output looks like below [image: 8db35596-b2c2-4360-a93b-9d50176b225f.png]
  • QML: "Cannot assign Derived to Base"

    Solved
    9
    0 評價
    9 貼文
    772 瀏覽
    A
    Well, that's too bad. :( Thanks for your help. I've applied a workaround like this in Point: Q_PROPERTY(QGeoCoordinate coordinates READ coordinates CONSTANT) const QGeoCoordinate &coordinates() const { return *this; } And seems to do the job. It's not ideal, since I also have a QList<Point> (used in a Repeater in QML), and there I need to make a copy of the list with casted objects. But if that's the only way it can work now... so be it. :)
  • QtQuick.Dialogs is missing Qt 6.1.3 / Qt 6.2.0

    Unsolved
    2
    0 評價
    2 貼文
    658 瀏覽
    sierdzioS
    I think it's not available in Qt 6, but the one from Labs should work: https://doc.qt.io/qt-6/qml-qt-labs-platform-messagedialog.html
  • Qml Module Not Found But App is running

    Solved
    5
    0 評價
    5 貼文
    7k 瀏覽
    raven-worxR
    @Enes-Alp then its an issue with QtCreator not parsing source files of .pri files
  • Howto reset QML interface

    Solved
    11
    0 評價
    11 貼文
    1k 瀏覽
    P
    @raven-worx Q_PROPERTY will notify the view about the changes. At first I thought that my cpp logic can change the objects and in-order to reflect those changes in QML, I've to reset the ContextProperty() but now I understood, I don't need resetModel() at all as Q_PROPERTY notify signal will done this behind the scenes. Thanks
  • Reset a QML property from Javascript

    Unsolved
    4
    0 評價
    4 貼文
    550 瀏覽
    raven-worxR
    @EddieC on what properties did you try it exactly? maybe the property does not have a reset method defined?
  • QML plugin: how to export mixed C++ and QML content

    Unsolved qml plugins designer qmltypes qtquick
    1
    0 評價
    1 貼文
    510 瀏覽
    尚無回覆
  • [Solved] Editing and saving indexed roles to Settings

    Unsolved
    6
    0 評價
    6 貼文
    355 瀏覽
    MarkkyboyM
    @fcarney - thanks again, this is taking shape now. There are a few odd behaviours which I will try to nail down, but largely, I am now able to edit price, name and type, close and open again with all my changes being present! yay! Regards,
  • CMake/VS2019: Specified module could not be found

    Unsolved
    3
    0 評價
    3 貼文
    694 瀏覽
    J
    @Crisian-Adam-0 I have verified that the file does exist at that location. I receive the same errors when attempting to run in Release mode.
  • QML SystemInfo - it exists already, but only seems to be part of the Neptune 3 UI

    Unsolved
    3
    0 評價
    3 貼文
    335 瀏覽
    V
    @raven-worx So what you are saying is what I said in the first few lines of my post, that I have to write what has already been written, is already documented by Qt as existing, is a direct reflection of what already exists in C++ because Qt decided to wrap it up in a "special" Neptune UI package. Not that it does ANYTHING relative to 3D or provides ANY additional information beyond that in the C++ class, so it in no way justifies a "special" package. But sure, why not use C++ to do what QML fails to do. Or why not just use a Qt Python package if you want your UI development to be separate from your core. Sort of removes having to dance around the not complete javascript to add a bit of functionality.
  • Dynamically load QML components together with the C++ context.

    Unsolved
    1
    0 評價
    1 貼文
    171 瀏覽
    尚無回覆
  • How to create single QML file with all the constants or labels so that it can reused

    Unsolved
    2
    0 評價
    2 貼文
    582 瀏覽
    raven-worxR
    @MaruthiMarsh create a singleton componen: https://wiki.qt.io/Qml_Styling#Approach_2:_Style_Singleton
  • how to redraw certain items of a Calendar or just the selected one?

    Unsolved
    2
    0 評價
    2 貼文
    305 瀏覽
    mbruelM
    well I suppose it is not possible... I'm redrawing all the items (delegates). As an update() is not doing the job, I'm using a "fake" binding like suggested here.