Hi there

I just need to align icon in QTableWidget. I found solution for it. So I should simple override QAbstractItemView::viewOptions.
So I did it.

But my overridden method is never called and it drives me nuts.

My code looks like this

Qt Code:
  1. #include <QTableWidget>
  2.  
  3. class CMyTable : public QTableWidget
  4. {
  5. public:
  6. CMyTable (QWidget *parent);
  7. ~CMyTable (void);
  8.  
  9. protected:
  10.  
  11. QStyleOptionViewItem viewOptions() const override;
  12. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. QStyleOptionViewItem CMyTable ::viewOptions() const
  2. {
  3. QStyleOptionViewItem option = QTableWidget::viewOptions();
  4. option.decorationAlignment = Qt::AlignHCenter | Qt::AlignCenter;
  5. option.decorationPosition = QStyleOptionViewItem::Top;
  6.  
  7. return option;
  8. }
To copy to clipboard, switch view to plain text mode 

Please if anybody knows what can be problem please let me know.