hi jpn,
today i m finally done with the border highlighting part. Thanks a lot for help.

But there is one more thing that is happening. i want that only the border is highlighted and not the background turns blue. i used the paint function and overrided it in my class's .cpp file. now one problem occurs.
the paint function paints the table created to white and not the color i selected. also it suppresses the effect of the drawFocus function and no focus is seen in the table.

i tried using palette in the table but can't make it work.

can u suggest somethng in that.

my code is as follows.


Qt Code:
  1. //griddelegate.h
  2. class GridDelegate : public QItemDelegate
  3. {
  4.  
  5. public:
  6.  
  7. GridDelegate(QObject *parent = 0);
  8.  
  9. void drawFocus(QPainter* painter,
  10. const QStyleOptionViewItem &option,
  11. const QRect &rect) const;
  12.  
  13. void paint(QPainter * painter,
  14. const QStyleOptionViewItem & option,
  15. const QModelIndex & index ) const;
  16.  
  17.  
  18. };
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. //griddelegate.cpp
  2.  
  3. #include <QtGui>
  4. #include <GridDelegate.h>
  5.  
  6. GridDelegate::GridDelegate(QObject *parent) : QItemDelegate(parent)
  7. {
  8.  
  9. }
  10.  
  11. void GridDelegate::paint(QPainter * painter,
  12. const QStyleOptionViewItem & option,
  13. const QModelIndex & index ) const
  14. {
  15.  
  16. if (option.state & QStyle::State_Selected)
  17. {
  18. QBrush brsh(Qt::red);
  19. painter->setBrush(brsh);
  20. }
  21. else if (option.state & QStyle::State_HasFocus)
  22. {
  23. QBrush brsh1(Qt::red);
  24. painter->setBrush(brsh1);
  25. }
  26.  
  27. }
  28.  
  29. void GridDelegate::drawFocus(QPainter* painter,
  30. const QStyleOptionViewItem &option,
  31. const QRect &rect) const
  32.  
  33. {
  34. if (option.state & QStyle::State_HasFocus)
  35.  
  36. {
  37.  
  38. QPen pen(Qt::black);
  39.  
  40. pen.setWidth(3);
  41.  
  42. painter->setPen(pen);
  43.  
  44. painter->drawRect(rect);
  45.  
  46. } else
  47. if (option.state & QStyle::State_Active)
  48.  
  49. {
  50.  
  51. QPen pen(Qt::green);
  52.  
  53. pen.setWidth(5);
  54.  
  55. painter->setPen(pen);
  56.  
  57. painter->drawRect(rect);
  58.  
  59. } else
  60. if (option.state & QStyle::State_KeyboardFocusChange)
  61.  
  62. {
  63.  
  64. QPen pen(Qt::black);
  65.  
  66. pen.setWidth(5);
  67.  
  68. painter->setPen(pen);
  69.  
  70. painter->drawRect(rect);
  71.  
  72. }
  73. }
To copy to clipboard, switch view to plain text mode 


in the constructor of my main program, i merely call the setItemDelegate function as suggested by u.