Results 1 to 20 of 47

Thread: A few queries about Model View Programming

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: A few queries about Model View Programming

    Quote Originally Posted by wysota View Post
    Haven't you seen any example that does that? In general you must be able to return data for both roles - QString for DisplayRole and QIcon or QPixmap for DecorationRole.
    I'll try searching the Qt example for the icon thing. I managed to get the icon along with the song name. Here's the code:

    if (role == Qt:ecorationRole && index.column() == 0) {
    QPixmap pixmap ("icon.png");
    return pixmap;
    }
    So, in the end it was pretty simple to get the icon.

    Quote Originally Posted by wysota View Post
    If you don't know which model to use, QStandardItemModel is almost always a good choice. If you are using a database though, you might want to use QSqlQueryModel or one of its descendants.
    I have decided to use QAbstractTableModel as it fits my requirements perfectly.

    Quote Originally Posted by wysota View Post
    Bad choice.

    QList<MyStruct> is much better.
    Actually the data from the database is already coming as a QStringList so i have to use a QList of QStringList, so i have no choice here.

    Quote Originally Posted by wysota View Post
    By setting a custom delegate and using QStyle::drawPrimitive() and PE_IndicatorCheckBox.
    But using custom delegate i think the custom drawing will only be visible to the user when it goes into edit mode. I want the custom drawing to be visible at all times. Currently the normal checkbox (using QCheckBoxRole) is visible at all times, so i just want to add custom drawing to it. But i am not sure how to draw it as it's not a real checkbox, so a normal custom delegate might not work.
    Last edited by montylee; 17th December 2008 at 22:48.

Similar Threads

  1. hierarchical model in a flat view
    By gniking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 20:17
  2. model View programming problem
    By mismael85 in forum Qt Programming
    Replies: 3
    Last Post: 2nd April 2008, 21:44
  3. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  4. Model - View Programming doubt.
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 13:01
  5. Replies: 6
    Last Post: 20th April 2006, 10:23

Tags for this Thread

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.