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. Qlist in Qtreeview
Forum Updated to NodeBB v4.3 + New Features

Qlist in Qtreeview

Scheduled Pinned Locked Moved General and Desktop
qlistqlistview
4 Posts 2 Posters 1.8k Views 2 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.
  • G Offline
    G Offline
    Gillou_beginqt
    wrote on last edited by
    #1

    Is it possible to display a Qlist of string values in a QtreeView? If possible how?

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

      Hi,

      Yes it is:

          QApplication app(argc, argv);
          QStringList stringList;
          stringList << "String1" << "String2" << "String3";
          QStringListModel *model = new QStringListModel(stringList);
          QTreeView view;
          view.setModel(model);
          view.show();
          return app.exec();
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Yes it is:

            QApplication app(argc, argv);
            QStringList stringList;
            stringList << "String1" << "String2" << "String3";
            QStringListModel *model = new QStringListModel(stringList);
            QTreeView view;
            view.setModel(model);
            view.show();
            return app.exec();
        
        G Offline
        G Offline
        Gillou_beginqt
        wrote on last edited by
        #3

        @SGaist And if I am using a custom model?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Well, your model should then return one column and the string list size as row count. Then data should return the appropriate string from the list

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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