Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to remove dotted-lines in QTreeview
Forum Updated to NodeBB v4.3 + New Features

How to remove dotted-lines in QTreeview

Scheduled Pinned Locked Moved General and Desktop
8 Posts 7 Posters 10.0k 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.
  • L Offline
    L Offline
    leonidwang
    wrote on last edited by
    #1

    Hi, all
    I'd like to remove the "dotted-lines" in QTreeview, by dotted-lines, I mean the area in red circle of this picture.

    Google told me to
    @treeView->setStyleSheet(QString("QTreeView::branch { border-image: none; }"));@
    or re-implement
    @void QTreeView::drawBranches ( QPainter * painter, const QRect & rect, const QModelIndex & index ) const@

    These methods kind of works, but they left the "dotted-lines" area as blank, while I want to totally remove them, i.e. the tree items will move to the left a bit and no blank area on the left side.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      I don't know.

      I think you should watch docs. Maybe you should inherit "QTreeView".

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        -Nevermind.-

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Hi,

          you could derive from QTreeView and reimplement "drawBranches":http://doc.qt.nokia.com/4.7/qtreeview.html#drawBranches

          You could use style sheets (see "style sheets, search for QTreeView":http://doc.qt.nokia.com/4.7/stylesheet-reference.html#list-of-stylable-widgets or the "QTreeView style example":http://doc.qt.nokia.com/4.7/stylesheet-examples.html#customizing-qtreeview )

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            auri
            wrote on last edited by
            #5

            Call QTreeView::setRootIsDecorated(false)

            DON'T PANIC!!

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rimen
              wrote on last edited by
              #6

              "This property holds indentation of the items in the tree view":http://developer.qt.nokia.com/doc/qt-4.8/qtreeview.html#indentation-prop for manipulate blank area on the left side.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                ken_liu
                wrote on last edited by
                #7

                Can't see the picture, but if you mean when item selected, and the dotted rectangle appeared.
                Maybe you can try

                @
                QTreeWidgetItem *item;
                item->setFlags(Qt::NoItemFlags);
                @

                or just remove 「ItemIsSelectable」flag.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  ken_liu
                  wrote on last edited by
                  #8

                  Can't see the picture, but if you mean when item selected, and the dotted rectangle appeared.
                  Maybe you can try

                  @
                  QTreeWidgetItem *item;
                  item->setFlags(Qt::NoItemFlags);
                  @

                  or just remove 「ItemIsSelectable」flag.

                  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