Results 1 to 19 of 19

Thread: foreach or alike

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: foreach or alike

    How about subclassing the model and reimplementing data() to return the proper icon for Qt::DecorationRole of each respective index?
    Last edited by wysota; 1st January 2012 at 20:16.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: foreach or alike

    Sorry but would you be able to show an example of subclassing a model that seems like the perfect way to go

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

    Default Re: foreach or alike

    Don't you know how to implement a subclass in C++?

    Qt Code:
    1. class MyModel : public QSqlQueryModel {
    2. public:
    3. MyModel(...) : QSqlQueryModel(...) {}
    4.  
    5. QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const {
    6. // put your stuff here
    7. }
    8. };
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. foreach error while compiling
    By smanoj in forum Newbie
    Replies: 4
    Last Post: 24th November 2011, 05:32
  2. QSplitter Skype-alike
    By davideanastasia in forum Newbie
    Replies: 3
    Last Post: 2nd June 2011, 14:26
  3. foreach QTextEdit in Layout
    By slc in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2010, 00:45
  4. lifetime of foreach
    By BalaQT in forum Newbie
    Replies: 4
    Last Post: 4th March 2010, 15:55
  5. Foreach performance
    By jano_alex_es in forum General Programming
    Replies: 2
    Last Post: 17th November 2009, 13:26

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.