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. Adding tree view to form in Qt Designer - from scratch , not in code
Forum Updated to NodeBB v4.3 + New Features

Adding tree view to form in Qt Designer - from scratch , not in code

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.2k Views 3 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am looking at this example.
    It implements tree view in code.
    I like to learn how to do same in Qt Designer - graphically.

    There are other , similar , "in code " examples.
    I have not found ANY examples of tree view in QT Designer / GUI form.

    Is that even feasible to implement using Qt Designer only ?
    Sample reference will be appreciated.

    https://doc.qt.io/qt-5/qtwidgets-itemviews-simpletreemodel-example.html

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AnneRanch said in Adding tree view to form in Qt Designer - from scratch , not in code:

      Is that even feasible to implement using Qt Designer only ?

      Hi
      Not really as while you can place the TreeView visually, the model construction and
      the assignment is only possible via code.

      So unlike TreeWidget, you will have to use code to give it the data.

      1 Reply Last reply
      3
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        QTreeView is just a view that shows a QAbstractItemModel. QAbstractItemModel, as the name suggests, is abstract, meaning it has no implementation and thus can't be really used in the designer. You can only place the view in designer, but you need to implement the model yourself as the possibilities are pretty much endless and that's not something you could represent in the designer.

        QTreeWidget on the other hand is a view and it has internal implementation of QAbstractItemModel that operates on QTreeWidgetItems. Since this is a concrete implementation with concrete behavior and is not abstract it is available to use in the designer.

        A 1 Reply Last reply
        3
        • Chris KawaC Chris Kawa

          QTreeView is just a view that shows a QAbstractItemModel. QAbstractItemModel, as the name suggests, is abstract, meaning it has no implementation and thus can't be really used in the designer. You can only place the view in designer, but you need to implement the model yourself as the possibilities are pretty much endless and that's not something you could represent in the designer.

          QTreeWidget on the other hand is a view and it has internal implementation of QAbstractItemModel that operates on QTreeWidgetItems. Since this is a concrete implementation with concrete behavior and is not abstract it is available to use in the designer.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @Chris-Kawa

          Thanks Chris,
          I will go for QTreeWidget, it will do the job.

          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