hello.
I wish create a delegate that draw an icon with two state raised and pushed based on the state of the button.
I think to draw a QStyleOptionButton with the icon , but my code don't work.
Qt Code:
  1. void CustomItemDelegate::paint(QPainter *painter,
  2. const QStyleOptionViewItem &option,
  3. const QModelIndex &index) const
  4. {
  5. /*const QAbstractListModel* model =
  6.   static_cast<const QAbstractListModel*>(index.model());
  7.   QStandardItem* item = model->item(index.row());*/
  8.  
  9.  
  10. QString text = "pipo";
  11. QRect rect = option.rect;
  12.  
  13. QRect textRect( rect);
  14. textRect.setHeight( 30);
  15. painter->drawText(textRect,text);
  16.  
  17. QRect buttonRect( rect);
  18. buttonRect.setY(textRect.y()+ 35);
  19. buttonRect.setHeight( 30);
  20. QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));
  21.  
  22. button.icon = undoicon;
  23. button.iconSize = QSize(32,32);
  24.  
  25. button.rect = buttonRect;
  26. button.text = text;
  27. button.state = _state | QStyle::State_Enabled;
  28.  
  29. QApplication::style()->drawControl
  30. (QStyle::CE_PushButton, &button, painter);
  31. }
To copy to clipboard, switch view to plain text mode 
my goal is to use a widget like the widgetbox desingner but with a pressed /raised icon.
Immagine.jpg
Is possible ?