Note that there are some explanatory texts on larger screens.

plurals
  1. POReducing the size of a QMdiSubWindow holding a QLabel with QPixmap
    primarykey
    data
    text
    <p>The question statement says it all. I am able to enlarge the QMdiSubWindow (and the pixmap scales UP, i.e. enlarges, appropriately) but I am not able to reduce its size (i.e. scale the image DOWN or shrink). When trying to scale down though, the border handles of the QMdiSubWindow remain rigidly fixed.</p> <p>The code I am using is as follows:</p> <pre><code>class PixmapWidget : public QLabel { Q_OBJECT public: PixmapWidget(): QLabel() { _pixmap = QPixmap("path\\to\\image.jpg"); setPixmap(_pixmap); _layout = new QHBoxLayout(); _layout-&gt;setSizeConstraint(QLayout::SetNoConstraint); setLayout(_layout); setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); } void resizeEvent(QResizeEvent * event) { int width = event-&gt;size().width(); int height = event-&gt;size().height(); setPixmap(_pixmap.scaled(width,height)); QLabel::resizeEvent(event); } protected: QPixmap _pixmap; QHBoxLayout* _layout; }; int main() { QMainWindow mainWindow; QHBoxLayout* layout = new QHBoxLayout(); QMdiArea* mdiArea = new QMdiArea(); mainWindow.setCentralWidget(mdiArea); mainWindow.centralWidget()-&gt;setLayout(layout); layout-&gt;setSizeConstraint(QLayout::SetNoConstraint); QMdiSubWindow* mdiSubWindow = new QMdiSubWindow(); layout-&gt;addWidget(mdiSubWindow); mdiSubWindow-&gt;setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); mdiSubWindow-&gt;layout()-&gt;setSizeConstraint(QLayout::SetNoConstraint); DMSQt::PixmapWidget pixmapWidget; mdiSubWindow-&gt;layout()-&gt;addWidget(&amp;pixmapWidget); mainWindow.show(); qapp.exec(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload