PDA

View Full Version : override QAbstractItemView::viewOptions never called



elanius
25th September 2013, 16:13
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



#include <QTableWidget>

class CMyTable : public QTableWidget
{
public:
CMyTable (QWidget *parent);
~CMyTable (void);

protected:

QStyleOptionViewItem viewOptions() const override;
};




QStyleOptionViewItem CMyTable ::viewOptions() const
{
QStyleOptionViewItem option = QTableWidget::viewOptions();
option.decorationAlignment = Qt::AlignHCenter | Qt::AlignCenter;
option.decorationPosition = QStyleOptionViewItem::Top;

return option;
}


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