How do i resize the contents of a QScrollArea as more widgets are placed inside

前端 未结 3 1185
悲哀的现实
悲哀的现实 2020-12-05 13:58

I have a QScrollArea Widget, which starts empty;

\"empty

It has a vertical layout, with a

3条回答
  •  悲哀的现实
    2020-12-05 14:11

    Why don't you use a QListView for your rows, it will manage all the issues for you? Just make sure that after you add it you click on the Class (top right window of designer) and assign a layout or it wont expand properly.

    I use a QLIstWidget inside a QScrollArea to make a scrollable image list

    Try this for adding other objects to the list, this is how I add an image to the list.

    QImage& qim = myclass.getQTImage();
    
    QImage iconImage = copyImageToSquareRegion(qim, ui->display_image->palette().color(QWidget::backgroundRole()));
    
    QListWidgetItem* pItem = new QListWidgetItem(QIcon(QPixmap::fromImage(iconImage)), NULL);
    
    pItem->setData(Qt::UserRole, "thumb" + QString::number(ui->ImageThumbList->count()));  // probably not necessary for you
    
    QString strTooltip = "a tooltip"
    
    pItem->setToolTip(strTooltip);
    
    ui->ImageThumbList->addItem(pItem);
    

提交回复
热议问题