Qt Quick Controls 1 Style

  • I would like to to change the itembranchindicator for a QtQuick.Controls TreeView (the little triangle before an item in a TreeView). When looking int qml/QtQuick/Controls/Styles/Desktop I don't see any icon or text property set, so how can one style this?

  • If I choose e.g. the Flat style, the treeView looks like this:

    Here the text indicators at the left of the items are incorrectly placed. How could one fix this?

  • Can you tell me how the styles work? I read (http://doc.qt.io/qt-5/qtquick-controls-styles-qmlmodule.html ) that one can set styles. Is the default Linux/Windows style not a style in that sense?

    I see in qquickstyleitem.cpp there is the line?

          case ItemBranchIndicator:
              qApp->style()->drawPrimitive(QStyle::PE_IndicatorBranch, m_styleoption, painter);

    Is this where the itembranchindicator gets set?

    Would it be possible to make a small custom style which is the same as the default style but replaces the itembranchindicator?

  • In order to make changes I tried using a TreeViewStyle:

    TreeView {
      id: treeView
      model: treeModel  
      anchors.fill: parent
      style: teststyle
      TableViewColumn {
        width: 270
        id: namecolumn
        title: "Name"
        role: "ParName"
      TableViewColumn {
        id: namecolumn2
        title: "value"
        role: "ParValue"
        delegate: valueDelegate
    TreeViewStyle {
      id: teststyle
      branchDelegate: Item {
        width: indentation
        height: 16
        Text {
          visible: styleData.column === 0 && styleData.hasChildren
          text: styleData.isExpanded ? "\u25bc" : "\u25b6"
          color: !control.activeFocus || styleData.selected ? styleData.textColor : "#666"
          font.pointSize: 10
          renderType: Text.NativeRendering
          style: Text.PlainText
          anchors.centerIn: parent
          anchors.verticalCenterOffset: 2

    but then I get the following error

    file:///home/Qt/5.10.0/gcc_64/qml/QtQuick/Controls/ScrollView.qml:365: TypeError: Cannot read property 'padding' of null
    file:///home/Qt/5.10.0/gcc_64/qml/QtQuick/Controls/ScrollView.qml:364: TypeError: Cannot read property 'padding' of null
    file:///home/Qt/5.10.0/gcc_64/qml/QtQuick/Controls/ScrollView.qml:363: TypeError: Cannot read property 'padding' of null
    file:///home/Qt/5.10.0/gcc_64/qml/QtQuick/Controls/ScrollView.qml:362: TypeError: Cannot read property 'padding' of null
    qrc:/ParameterSettings.qml:14:8: Unable to assign TreeViewStyle_QMLTYPE_104 to QQmlComponent

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.