Results 1 to 5 of 5

Thread: tree view!!

  1. #1
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default tree view!!

    tree.png

    hi all,
    Can some body explain how to implement this tree view.

    Thanks in advance,
    Seema Rao

  2. #2
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: tree view!!

    Hi..

    Use the QTreeWidget and then QTreeWidgetItem to create it..
    With this you can set the image with every tree item and can subclass it in any hierarchy u need..

    Kapil
    All you have to decide is what to do with the time that is given to you

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: tree view!!

    Or QTreeView and a model of your choice.

  4. #4
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: tree view!!

    I tried to create a simple tree view, but no tree appears, Am I doing any thing wrong here??
    #include <QApplication>
    #include <QtGui>
    int main(int argc, char *argv[])

    {
    QApplication app(argc, argv);

    QWidget *widget = new QWidget;
    QTreeWidget *treeWidget= new QTreeWidget;

    QTreeWidgetItem *cities = new QTreeWidgetItem(treeWidget);
    cities->setText(0, "Cities");
    QTreeWidgetItem *osloItem = new QTreeWidgetItem(cities);
    osloItem->setText(0, "Oslo");
    osloItem->setText(1, "Yes");

    treeWidget->addTopLevelItem(cities);

    QVBoxLayout *mylayout= new QVBoxLayout;
    mylayout->addWidget(treeWidget);

    widget->setLayout(mylayout);
    widget->show();

    app.exec();
    }
    Thanks in advance,
    Seema

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: tree view!!

    Add:
    Qt Code:
    1. treeWidget->setColumnCount(2);
    To copy to clipboard, switch view to plain text mode 
    after you create the tree widget.

Similar Threads

  1. Radio buttons in a tree view
    By notwithstanding in forum Qt Programming
    Replies: 6
    Last Post: 3rd November 2008, 23:32
  2. Tree View with Icons/primitives
    By dosto.walla in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2008, 11:29
  3. Replies: 2
    Last Post: 18th March 2008, 16:38
  4. Ignore mouse events out of tree view
    By krishna.bv in forum Qt Programming
    Replies: 3
    Last Post: 27th December 2006, 12:24
  5. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 09:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.