Results 1 to 20 of 70

Thread: How to show progess in a QTreeView item ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: How to show progess in a QTreeView item ?

    No, it won't.

    Qt Code:
    1. class Dele : public QItemDelegate {
    2. public:
    3. void paint(QPainter *p, const .... &opt, const QModelIndex &ind const {
    4. int val = ind.data(Qt::DisplayRole).toInt();
    5. QRect rect = opt.rect;
    6. rect.setWidth(rect.width()*val/100);
    7. p->drawRect(rect);
    8. }
    9. };
    10.  
    11. QTreeWidget Item *item = ....
    12.  
    13. item->setText(1, 40);
    14. // view will be updated here
    15. item->setText(1, 60);
    16. // view will be updated here
    To copy to clipboard, switch view to plain text mode 

    You have at least two almost complete solution on the very first page of this thread. Didn't you see them?

  2. The following 2 users say thank you to wysota for this useful post:

    Talei (20th January 2010), THRESHE (3rd March 2008)

  3. #2
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to show progess in a QTreeView item ?

    Thanks that is what I was asking you
    C++ & AMD forever

  4. #3
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to show progess in a QTreeView item ?

    And one more question I'd like to ask. I don't know if this is the right topic so don't blame me too much

    The problem is when I click on a row in my table widget it becomes highlighted but when I use delegates it is not. I've tried to do like this
    Qt Code:
    1. if (table->currentRow() == index.row())
    2. {
    3. painter->setBrush(QBrush(QColor("#444444")));
    4. painter->drawRect(opt.rect);
    5. }
    To copy to clipboard, switch view to plain text mode 
    but it didn't work the way I thought. Also I've tried to use setBackground with QPainter and that didn't work either
    C++ & AMD forever

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to show progess in a QTreeView item ?

    The QStyleOptionViewItem parameter contains all required information.
    Qt Code:
    1. if (opt.state & QStyle::State_Selected)
    2. ...
    3.  
    4. if (opt.state & QStyle::State_HasFocus)
    5. ...
    To copy to clipboard, switch view to plain text mode 
    etc.
    J-P Nurmi

  6. #5
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to show progess in a QTreeView item ?

    Quote Originally Posted by jpn View Post
    The QStyleOptionViewItem parameter contains all required information.
    Qt Code:
    1. if (opt.state & QStyle::State_Selected)
    2. ...
    3.  
    4. if (opt.state & QStyle::State_HasFocus)
    5. ...
    To copy to clipboard, switch view to plain text mode 
    etc.
    And what after ???
    I've tried like
    Qt Code:
    1. if (opt.state & QStyle::State_Selected)
    2. {
    3. painter->setBrush(QBrush(QColor("#444444")));
    4. painter->drawRect(opt.rect);
    5. }
    To copy to clipboard, switch view to plain text mode 
    Result -
    Attached Images Attached Images
    • File Type: jpg 1.jpg (6.3 KB, 36 views)
    C++ & AMD forever

  7. #6
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to show progess in a QTreeView item ?

    Sorry it was something with my brushes now it works fine
    C++ & AMD forever

Similar Threads

  1. Replies: 4
    Last Post: 26th September 2011, 12:02
  2. QTreeView and item editing
    By roxton in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:56
  3. QTreeView, QSortFilterProxyModel and item expansions
    By benacler in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2008, 20:30
  4. QTreeView: selection behavior upon selected item removal
    By Pieter from Belgium in forum Qt Programming
    Replies: 6
    Last Post: 11th July 2007, 16:00
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

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.