reimplementation of sizeHint() is empty for now. I am just having a qDebug() statement and exit(1) in sizeHint() to check if the function is actually getting called. But nothing is displayed and my program doesn't exit.
I am setting some options for the table view like allowing single selection, hiding headers etc. Can this be the reason that sizeHint() is not being called? It seems idiotic to me but this thought came to my mind.
Here's how i am reimplementing sizeHint():
Header file:
{
public:
// Public member functions
};
class CustomDelegate : public QAbstractItemDelegate
{
public:
CustomDelegate(QObject *parent=0);
// Public member functions
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
To copy to clipboard, switch view to plain text mode
C++ file:
{
// Paint implementation
}
{
qDebug("Inside sizeHint");
exit(1);
}
void CustomDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
// Paint implementation
}
QSize CustomDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
qDebug("Inside sizeHint");
exit(1);
}
To copy to clipboard, switch view to plain text mode
Now, when i run my application, paint() is called but sizeHint() is not getting called. I don't why sizeHint() is not being called
Bookmarks