I have a QGraphicsScene in a QGraphicsView that displays a scaled pixmap. For some reason, when the pixmap is larger than 32,767 pixels (max value of type int), it fails to show up at all or sometimes partially shows up.
The QGraphicsView documentation for QT5 says:
Note that although the scene supports a virtually unlimited size, the range of the scroll bars will never exceed the range of an integer (INT_MIN, INT_MAX).
However, I should be able to display a pixmap larger than 32,767 pixels because I printed INT_MIN and INT_MAX and they are INT_MIN = -2147483648, INT_MAX = 2147483647 on my system (I'm running an Intel processor on Ubuntu 14.04). What could cause the pixmap to not show up when it gets larger than 32,767 pixels in one dimension? As long as it's below 32,767 pixels, the image displays properly. Is this a bug in Qt? Code below.
// Transformation matrix
if(!time_vertical) {
matrix.scale(1, -1);
matrix.rotate(90);
}
matrix.scale(frequency_zoom, time_zoom);
// Create pixmap
pixmap.convertFromImage(*image);
pixmap = pixmap.transformed(matrix);
// Add pixmap to scene
scene->clear();
item->setPos(0, 0); // Set pixmap origin (0, 0) in scene coordinates
scene->setSceneRect(pixmap.rect());
// Transformation matrix
QMatrix matrix;
if(!time_vertical) {
matrix.scale(1, -1);
matrix.rotate(90);
}
matrix.scale(frequency_zoom, time_zoom);
// Create pixmap
pixmap.convertFromImage(*image);
pixmap = pixmap.transformed(matrix);
// Add pixmap to scene
scene->clear();
QGraphicsPixmapItem* item = scene->addPixmap(pixmap);
item->setPos(0, 0); // Set pixmap origin (0, 0) in scene coordinates
scene->setSceneRect(pixmap.rect());
To copy to clipboard, switch view to plain text mode
Bookmarks