跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k 主題 77.4k 貼文
  • Drag and Drop to desktop or file manager

    Unsolved
    2
    0 評價
    2 貼文
    548 瀏覽
    S
    Replying here just because it's the first hit on google for Drag.Automatic: there is an answer to this question here: https://stackoverflow.com/questions/24532317/new-drag-and-drop-mechanism-does-not-work-as-expected-in-qt-quick-qt-5-3. In short, you should replace Drag.active: mouseArea.drag.active by property bool dragActive: mouseArea.drag.active onDragActiveChanged: { if (dragActive) { Drag.start(); } else { Drag.drop(); } } More details in the SO post, apparently you can see the different code flows in the QQuickDrag code. Note that Drag.Automatic does work as expected when you use a DragHandler, just not when you use a MouseArea.
  • How to create a QML ListModel from a C++ structure ?

    Solved
    8
    0 評價
    8 貼文
    2k 瀏覽
    fcarneyF
    If you are using this structure in other code that you don't want to change. Then I would serialize and deserialize the list. It really depends upon how interactive you want it to be. Are you planning on having the changes update in the structure based upon actions by the user? In that case I would go for a model that allows things to be updated and immediately changed in the structure. If you want to just display and update the whole thing at once you can get by using the serialize method. QML ListModel's accept javascript structures: {name: "year", value: 22} You can build this value as a QVariantList with each entry being QVariantMap. Then return QVariantList to QML. Or you can emit a QVariantMap for each member. You won't be able to get around the tedious work this involves. No matter how you do this it will a lot of copy, paste, and edit. If you are thinking of changing how you store this in your program you could store the data in a way that is easier to serialize.
  • 此主題已被刪除!

    Unsolved
    1
    0 評價
    1 貼文
    30 瀏覽
    尚無回覆
  • How to auto change the width of rectangle under Repeater

    Solved
    3
    0 評價
    3 貼文
    840 瀏覽
    J
    @fcarney This helped me to fix the problem
  • gif uses a lot of memory, qml

    Unsolved
    6
    0 評價
    6 貼文
    582 瀏覽
    Q
    @jsulm i used other gifs and any gif increments app size at least 100 mb i wanna use gif just for icon of app (just one place)
  • Change Map language in QML Map element

    Unsolved
    2
    0 評價
    2 貼文
    301 瀏覽
    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 評價
    2 貼文
    728 瀏覽
    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 評價
    2 貼文
    399 瀏覽
    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 評價
    2 貼文
    599 瀏覽
    D
    Were you able to figure this out? I have the same issue.
  • Having the same issue.

    Unsolved
    1
    0 評價
    1 貼文
    127 瀏覽
    尚無回覆
  • Menus in Qt quick

    Solved
    3
    0 評價
    3 貼文
    314 瀏覽
    K
    @fcarney Thanks, this did it!
  • Howto expose ID of an element in an item ?

    Unsolved
    3
    0 評價
    3 貼文
    326 瀏覽
    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 貼文
    373 瀏覽
    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 貼文
    327 瀏覽
    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 貼文
    270 瀏覽
    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 貼文
    274 瀏覽
    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 貼文
    938 瀏覽
    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 貼文
    728 瀏覽
    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. :)