Vikram.Saralaya
30th July 2015, 14:16
I have a
QList< Qvector<uint> > structure to store pixel values of an image. There is a very fast image generator which continuously generates these images pixel by pixel. I need to display the pixels of the last generated image in my GUI.
So I created a QAbstractTableModel which will reference to the last generated image. I attached a QTableView to this. A QAbstractItemDelegate is delegated to paint the individual items in the QTableView.
void PixelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.state)
{
QColor color = index.model()->data(index, Qt::DisplayRole).value<QColor>();
painter->fillRect(option.rect, color);
}
}
Basically I am using QTableView to display an image! I also add this QTableView to a graphicsScene to zoom in and out of image etc. So I need to resize my QTableView everytime the size of the generated image changes to avoid scrollbars.
Question:
Looks like I am complicating things way too much for no reason?! Any suggestion would be useful.
Regards
Vikram :)
QList< Qvector<uint> > structure to store pixel values of an image. There is a very fast image generator which continuously generates these images pixel by pixel. I need to display the pixels of the last generated image in my GUI.
So I created a QAbstractTableModel which will reference to the last generated image. I attached a QTableView to this. A QAbstractItemDelegate is delegated to paint the individual items in the QTableView.
void PixelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.state)
{
QColor color = index.model()->data(index, Qt::DisplayRole).value<QColor>();
painter->fillRect(option.rect, color);
}
}
Basically I am using QTableView to display an image! I also add this QTableView to a graphicsScene to zoom in and out of image etc. So I need to resize my QTableView everytime the size of the generated image changes to avoid scrollbars.
Question:
Looks like I am complicating things way too much for no reason?! Any suggestion would be useful.
Regards
Vikram :)