Results 1 to 1 of 1

Thread: QAbstractTableModel , custom data

  1. #1
    Join Date
    Mar 2009
    Posts
    19
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QAbstractTableModel , custom data

    i am trying to color a particular column in AbstractTableModel. But I wonder why its not working.........Here is the code snipp....
    thanks.

    Qt Code:
    1. function ColorModel(parent)
    2. {
    3. QAbstractTableModel.call(this, parent);
    4. }
    5. ColorModel.prototype= new QAbstractTableModel();
    6.  
    7. ColorModel.prototype.rowCount= function (QModelIndex)
    8. {
    9. return 2;
    10. }
    11.  
    12. ColorModel.prototype.columnCount= function (QModelIndex)
    13. {
    14. return 5;
    15. }
    16. ColorModel.prototype.color=function(){
    17. return new QColor(127, 200 , 24);
    18. }
    19. ColorModel.prototype.data = function(index, role)
    20. {
    21. var dataR;
    22. if (role == Qt.DisplayRole) {
    23. return 5;
    24. }
    25. if (role == Qt.BackgroundRole) {
    26. if (index.column() == 1)
    27. //return new QColor(127, 200 , 24);
    28. return this.color;
    29. //var color = new RGBColor('darkblue');
    30. }
    31.  
    32. return dataR;
    33. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 17th April 2009 at 16:05. Reason: missing [code] tags

Similar Threads

  1. Convert between a custom data type wrapped in a QVariant
    By darkadept in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 09:07
  2. Best way to display lots of data fast
    By New2QT in forum Newbie
    Replies: 4
    Last Post: 16th October 2008, 22:46
  3. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 16:26
  4. Custom Model Class
    By mattjgalloway in forum Qt Programming
    Replies: 12
    Last Post: 4th June 2007, 17:30
  5. QVariant::toString and custom data types
    By Vladimir in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2007, 15:36

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.