Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • Change Map language in QML Map element

    Unsolved
    2
    0 Votes
    2 Posts
    301 Views
    M
    @Alisa said in Change Map language in QML Map element: MapParameter { type: "layout" property var layer: "country-label" property var textField: ["get", "name_de"] } Hi Have you found the sollution? Best Marek
  • How to use ItemSelectionModel with TableView

    Unsolved
    2
    0 Votes
    2 Posts
    724 Views
    GrecKoG
    @ocgltd said in How to use ItemSelectionModel with TableView: ItemSelectionModel.select | ItemSelectionModel.current It should be ItemSelectionModel.Select | ItemSelectionModel.Current
  • Q_PROPERTY typedef

    Solved
    2
    0 Votes
    2 Posts
    397 Views
    kshegunovK
    @vinci said in Q_PROPERTY typedef: Is the documentation on this out of date? What exactly are "type comparisons" in this context? Probably not out of date. I'd speculate it simply isn't telling the whole story. You can test this: Make your own typedef and do the Q_DECLARE_METATYPE and qRegisterMetatype stuff. Then try to use it as a type in the property. I suspect it should work. E.g. (split and reorder properly): namespace Test { Q_NAMESPACE enum TestEnum { MyValue }; Q_ENUM_NS(TestEnum) } using TestEnum = Test::TestEnum; class Bar : public QObject { Q_OBJECT Q_PROPERTY(TestEnum enum READ enum WRITE setEnum NOTIFY enumChanged) // ... code }; int main( ...) { qRegisterMetaType<TestEnum>("TestEnum"); // Do the QML init and such } @vinci said in Q_PROPERTY typedef: Yet types like QVariantMap are themself typedefs. E.g. QVariantMap is defined like this: Variants are very special. What exactly are "type comparisons" in this context? As in whether TestEnum is convertible to int, or other enums, or can be streamed to a binary buffer, etc. The metatype reflection stuff basically.
  • Qt Charts: StackedBarSeries with DateTimeAxis

    Unsolved
    2
    2 Votes
    2 Posts
    599 Views
    D
    Were you able to figure this out? I have the same issue.
  • Having the same issue.

    Unsolved
    1
    0 Votes
    1 Posts
    127 Views
    No one has replied
  • Menus in Qt quick

    Solved
    3
    0 Votes
    3 Posts
    313 Views
    K
    @fcarney Thanks, this did it!
  • Howto expose ID of an element in an item ?

    Unsolved
    3
    0 Votes
    3 Posts
    325 Views
    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 Votes
    3 Posts
    370 Views
    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 Votes
    5 Posts
    1k Views
    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") } } }
  • 0 Votes
    4 Posts
    326 Views
    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 Votes
    2 Posts
    270 Views
    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?
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • ShaderEffect on layer create weird artifacts on text

    Unsolved
    2
    0 Votes
    2 Posts
    272 Views
    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.
  • 0 Votes
    3 Posts
    934 Views
    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 Votes
    9 Posts
    723 Views
    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 Votes
    2 Posts
    632 Views
    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 Votes
    5 Posts
    7k Views
    raven-worxR
    @Enes-Alp then its an issue with QtCreator not parsing source files of .pri files
  • Howto reset QML interface

    Solved
    11
    0 Votes
    11 Posts
    1k Views
    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 Votes
    4 Posts
    514 Views
    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 Votes
    1 Posts
    484 Views
    No one has replied