Results 1 to 2 of 2

Thread: 3 questions about QTreeView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Posts
    41
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default 3 questions about QTreeView

    Hi !

    First of all, what is the difference between QTreeView and QTreeWidget ? The same applies for QListView and QListWidget.

    I want the first column of my QTreeView to display a checkbox. Here is my code :

    QStandardItem* item0 = new QStandardItem();
    item0->setCheckable(true);
    item0->setCheckState(Qt::Checked);
    item0->setAccessibleText(false);
    item0->setEditable(false);

    It works great but I have seeked for how to center the checkbox in the column and didn't find anything. There is no text in that column, only a checkbox.

    And finally, I wonder how to add a combox in my tree and even if it is possible within a QTreeView. I don't especialy need a QTreeView, only a "list"-style widget.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 3 questions about QTreeView

    Quote Originally Posted by Guilo View Post
    First of all, what is the difference between QTreeView and QTreeWidget ? The same applies for QListView and QListWidget.
    The first is to use with a model, the second is item based. Read the docs about Model/View programming.
    I want the first column of my QTreeView to display a checkbox. Here is my code :

    QStandardItem* item0 = new QStandardItem();
    item0->setCheckable(true);
    item0->setCheckState(Qt::Checked);
    item0->setAccessibleText(false);
    item0->setEditable(false);

    It works great but I have seeked for how to center the checkbox in the column and didn't find anything. There is no text in that column, only a checkbox.
    if inside a view: see your delegate.

    And finally, I wonder how to add a combox in my tree and even if it is possible within a QTreeView. I don't especialy need a QTreeView, only a "list"-style widget.
    Guess I don't understand your question: use QListView? And for the combo box: also see the item delegate or for a list widget: QListWidget::setItemWidget().

  3. The following user says thank you to Lykurg for this useful post:

    Guilo (21st February 2010)

Similar Threads

  1. Some questions for Qt?
    By tszzp in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2009, 09:46
  2. QTreeView/WIdget questions
    By Mystical Groovy in forum Qt Programming
    Replies: 3
    Last Post: 22nd October 2009, 12:39
  3. A few questions
    By T3AB4GG3R117 in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 08:01
  4. 2 little questions
    By kib2 in forum Qt Tools
    Replies: 5
    Last Post: 25th October 2008, 16:25
  5. QTreeView questions about view doubles and more
    By davisjamesf in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 00:39

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
  •  
Qt is a trademark of The Qt Company.