Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Overwrite internal properties
Qt 6.11 is out! See what's new in the release blog

Overwrite internal properties

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    onek24
    wrote on last edited by
    #1

    Hello,

    is it possible to overwrite internal properties, for example: I need to overwrite the __popupStyle property:
    @property Component __popupStyle: Style {

        property Component frame: Rectangle {
            width: (parent ? parent.contentWidth : 0)
            height: (parent ? parent.contentHeight : 0) + 2
            border.color: "white"
            property real maxHeight: 500
            property int margin: 1
        }
    
        property Component menuItem: Text {
            text: "NOT IMPLEMENTED"
            color: "red"
            font {
                pixelSize: 14
                bold: true
            }
        }
    
        property Component scrollerStyle: Style {
            padding { left: 0; right: 0; top: 0; bottom: 0 }
            property bool scrollToClickedPosition: false
            property Component frame: Item { visible: false }
            property Component corner: Item { visible: false }
            property Component __scrollbar: Item { visible: false }
            property bool useScrollers: true
        }
    }@
    

    in the ComboBoxStyle.qml. But i want to overwrite it locally, so it should somehow like that:

    @import QtQuick 2.2
    import QtQuick.Controls 1.1
    import QtQuick.Controls.Styles 1.1
    import QtQuick.Controls.Private 1.0

    ComboBox {
    width: 100; height: 30
    model: ["Hello i am a very long string.", "Hello i am a very very long string."]
    style: ComboBoxStyle {
    __popupStyle: Style {
    property Component frame: Rectangle {
    width: (parent ? parent.contentWidth : 0)
    height: (parent ? parent.contentHeight : 0) + 2
    border.color: "white"
    property real maxHeight: 500
    property int margin: 1
    }
    property Component menuItem: Text {
    text: "NOT IMPLEMENTED"
    color: "red"
    font {
    pixelSize: 14
    bold: true
    }
    }
    property Component scrollerStyle: Style {
    padding { left: 0; right: 0; top: 0; bottom: 0 }
    property bool scrollToClickedPosition: false
    property Component frame: Item { visible: false }
    property Component corner: Item { visible: false }
    property Component __scrollbar: Item { visible: false }
    property bool useScrollers: true
    }
    }
    }
    }@
    It detects the property but i can't overwrite it.

    To my questions: Is it possible to overwrite a property Component, if yes, how?

    -- Update --

    It looks like it is possible to overwrite and it also looks like i am theoretically doing it correct. I am searching for the drop-down list/popup properties, am i on the wrong way?

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onek24
      wrote on last edited by
      #2

      Found the property component i was searching for in the MenuStyle.qml which is used by Menu which is used by ComboBox. I am using a ComboBox and i need to change or overwrite this property:

      @property Component menuItem: Rectangle{...}@

      Is there any possibility for me to do that only for one ComboBox?
      I really dont want to replace multiple control-components and styles with custom ones...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved