Results 1 to 3 of 3

Thread: QListView

  1. #1
    Join Date
    Aug 2006
    Posts
    83

    Default QListView

    Hello,

    I habe a problem with a qlistview. I have several items in it, but when i delete them i want to display text:"no items in listview" but i don't know how to do this. Any ideas?? The problem is that i don't know how to display the text (how?) ?

    I need something equivalent to this-> void Q3Canvas::setBackgroundPixmap ( const QPixmap & p ) [virtual]
    Last edited by moowy; 2nd October 2006 at 14:59.

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

    Default Re: QListView

    You could for example override list view's paint event and draw the text by hand in case there is no items.

    Qt Code:
    1. void MyListView::paintEvent(QPaintEvent* event)
    2. {
    3. QListView::paintEvent(event); // let the list view draw itself as it would
    4.  
    5. // special case when there is no items
    6. if (model()->rowCount() == 0)
    7. {
    8. QPainter p(viewport());
    9. p.drawText(rect(), Qt::AlignCenter, "No items..");
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    Not sure if it works as desired or if it even compiles, but it should give you an idea..
    J-P Nurmi

  3. #3
    Join Date
    Aug 2006
    Posts
    83

    Default Re: QListView

    It works. Thanks (if you're wondering: u're code compiles perfectly without modifications)

Similar Threads

  1. How can I disable the QListView Sorting?
    By darpan in forum Qt Programming
    Replies: 3
    Last Post: 27th June 2006, 11:36
  2. Key Events for QListView
    By bmesing in forum Qt Programming
    Replies: 2
    Last Post: 4th April 2006, 10:29
  3. .gif and .tiff image type in QListView in QT3.3.5
    By darpan in forum Qt Programming
    Replies: 5
    Last Post: 18th March 2006, 05:31
  4. moving Qlistview items
    By :db:sStrong in forum Qt Programming
    Replies: 0
    Last Post: 21st February 2006, 13:25
  5. Keeping focus at bottom of QListView
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2006, 15:45

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.