Results 1 to 6 of 6

Thread: Star Delegate Example

  1. #1
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Star Delegate Example

    Hello,
    If using a model/view based on QSqlRelationalTableModel/QTableView, can i use this delegate to handle one column of the view that holds the appropriate data(int in the range of 1 to 5)?
    Showld't it be as simple as...
    Qt Code:
    1. ...
    2. view->setItemDelegateForColumn(3, new StarDelegate);
    3. ...
    To copy to clipboard, switch view to plain text mode 

    Thanks

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Star Delegate Example

    Reading from the docs ,,yes.
    It would have cost you less time testing urself

  3. #3
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Star Delegate Example

    I had done it before i asked
    I get no error and the star delegate never shows up!
    Must be doing something "stupid"... i will take a better look.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Star Delegate Example

    check the trigger modes if you have set on the view if any

  5. The following user says thank you to aamer4yu for this useful post:

    graciano (9th February 2010)

  6. #5
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Star Delegate Example

    Thanks ... i wĩll ... as soon as i get home.

  7. #6
    Join Date
    Sep 2008
    Location
    Portugal
    Posts
    171
    Thanks
    57
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Star Delegate Example

    I tried mixing the "spin box" and the "star" delegate examples like this:
    Qt Code:
    1. #include <QApplication>
    2. #include <QHeaderView>
    3. #include <QItemSelectionModel>
    4. #include <QStandardItemModel>
    5. #include <QTableView>
    6.  
    7. #include "delegate.h"
    8. #include "stardelegate.h"
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QApplication app(argc, argv);
    13. QStandardItemModel model(4, 2);
    14. QTableView tableView;
    15. tableView.setModel(&model);
    16. SpinBoxDelegate delegateForColumn0;
    17. StarDelegate delegateForColumn1;
    18. tableView.setItemDelegateForColumn(0, &delegateForColumn0);
    19. tableView.setItemDelegateForColumn(1, &delegateForColumn1);
    20. tableView.horizontalHeader()->setStretchLastSection(true);
    21. for (int row = 0; row < 4; ++row) {
    22. for (int column = 0; column < 2; ++column) {
    23. QModelIndex index = model.index(row, column, QModelIndex());
    24. model.setData(index, QVariant(row+1));
    25. }
    26. }
    27. tableView.setWindowTitle(QObject::tr("Spin Box/Star Delegates"));
    28. tableView.show();
    29. return app.exec();
    30. }
    To copy to clipboard, switch view to plain text mode 

    No stars yet?!

Similar Threads

  1. QTableView doesn't use delegate
    By treaves in forum Qt Programming
    Replies: 3
    Last Post: 1st February 2010, 10:45
  2. Delegate & widgets
    By zuck in forum Qt Programming
    Replies: 2
    Last Post: 12th August 2009, 10:41
  3. Another delegate problem...
    By alexandernst in forum Newbie
    Replies: 3
    Last Post: 9th August 2009, 15:14
  4. QTreeView Delegate
    By ^NyAw^ in forum Qt Programming
    Replies: 3
    Last Post: 23rd June 2009, 10:10
  5. Delegate but when
    By uygar in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2007, 21:28

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.