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. Qt Quick Controls 1 Style
Forum Updated to NodeBB v4.3 + New Features

Qt Quick Controls 1 Style

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 1 Posters 732 Views
  • 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.
  • M Offline
    M Offline
    maxwell31
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxwell31
      wrote on last edited by
      #2

      If I choose e.g. the Flat style, the treeView looks like this:
      0_1529413083898_Selection_060.png

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxwell31
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maxwell31
          wrote on last edited by
          #4

          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

          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