Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
qt滚动条中的并排图像_Qt_Qimage_Qscrollarea - Fatal编程技术网

qt滚动条中的并排图像

qt滚动条中的并排图像,qt,qimage,qscrollarea,Qt,Qimage,Qscrollarea,为了在Qt滚动区域小部件中查看图像,我编写了下面的代码 void ImageViewer::open(){ QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::homePath()); if (!fileName.isEmpty()) { QImage image(fileName); if (image.is

为了在Qt滚动区域小部件中查看图像,我编写了下面的代码

void ImageViewer::open(){
QString fileName = QFileDialog::getOpenFileName(this,
                                 tr("Open File"), QDir::homePath());
if (!fileName.isEmpty()) {
     QImage image(fileName);
     if (image.isNull()) {
         QMessageBox::information(this, tr("Image Viewer"),
                                  tr("Cannot load %1.").arg(fileName));
         return;
     }
     imageLabel->setPixmap(QPixmap::fromImage(image));
     scaleFactor = 1.0;

     printAct->setEnabled(true);
     fitToWindowAct->setEnabled(true);
     updateActions();

     if (!fitToWindowAct->isChecked())
         imageLabel->adjustSize();
  }
 }

现在我想在一个滚动区域中看到两三张图片,但不幸的是,我不知道该函数是什么,也不知道如何在一个滚动区域中并排放置三个图像。

使用QListWidget而不是QLabels:你的意思是没有任何方法可以使用QLabels?是的,你可以,但最简单的事情是使用QListWidgetIn,所以在互联网上有很多QScroolBar的示例,请查看它们,修改它们,当你尝试某件事情时,你只需发布一个问题,这样我们就不会做你的工作,请阅读