在Qt中显示图像的问题

时间:2014-05-28 23:55:08

标签: c++ qt

我正在尝试使用Qt打开1920x1080窗口并显示1920x1080图像。 问题在于它只填充了前810行 窗口,底部是空白的。奇怪的是,我可以滚动其余部分 用鼠标滚轮图像。我在下面列出了代码的重要部分。 有谁知道为什么Qt没有在全高度显示图像?

#define DISPLAY_WIDTH                           1920
#define DISPLAY_HEIGHT                          1080
#define QIMAGE_NUM_CHANNELS                     3
QImage *myQImage = new QImage(DISPLAY_WIDTH, DISPLAY_HEIGHT, QImage::Format_RGB888);

// This merely initializes the image  
for (int row = 0 ; row < DISPLAY_HEIGHT ; row+=1) {
    uchar *tmpImg = (uchar *) myQImage->scanLine(row);
    for (int col = 0 ; col < DISPLAY_WIDTH ; col++) {
        for (int c = 0 ; c < QIMAGE_NUM_CHANNELS ; c++) {
           tmpImg[(col * QIMAGE_NUM_CHANNELS) + c] = row%256;
        }
    }
}

QDialog *myQDialog = new QDialog(this);
myQDialog->setGeometry(0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT);
QGraphicsScene *myGraphicsScene = new QGraphicsScene;
myGraphicsScene->addPixmap(QPixmap::fromImage(*CompositeOneQImage));

QGraphicsView *myGraphicsView = new QGraphicsView(myGraphicsScene, myQDialog);
myGraphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
myGraphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
myQDialog->show();

0 个答案:

没有答案