Caius Aérobus
7th December 2007, 17:17
Hello,
I have a big image on the left and a stack of thumbnails on the right. The size of the image on the left is fixed and I would like to compute the size (actually only height) of every thumbnail so as to have the top of the first thumbnail and the bottom of the last one aligned with the image top and bottom on the left.
So my computation is (left_height - (n-1) * right_spacing) / n but the spacing returned by the vertical layout is -1! So, as said in the doc, the spacing is those of the parent layout (no one here) or of the parent widget (ww here), right? And is it a (easy) way to get it, since layout->parent() returns a QObject and not ww (probably because I did not create it as a child of ww)? or an easier way to constraint the thumbnails sizes?
w = new QWidget();
QHBoxLayout *LLayout = new QHBoxLayout();
w->setLayout(LLayout);
LLayout->addWidget(<some widget>);
QWidget *ww = new QWidget();
QVBoxLayout layout = new QVBoxLayout();
layout->setMargin(1);
layout->setSizeConstraint(QLayout::SetFixedSize);
ww->setLayout(layout);
layout->addWidget(<some widget>);
layout->addWidget(<some widget>);
layout->addWidget(<some widget>);
LLayout->addWidget(ww);
LLayout->setAlignment(ww, Qt::AlignTop);
printf("spacing=%d\n", layout->spacing());
I have a big image on the left and a stack of thumbnails on the right. The size of the image on the left is fixed and I would like to compute the size (actually only height) of every thumbnail so as to have the top of the first thumbnail and the bottom of the last one aligned with the image top and bottom on the left.
So my computation is (left_height - (n-1) * right_spacing) / n but the spacing returned by the vertical layout is -1! So, as said in the doc, the spacing is those of the parent layout (no one here) or of the parent widget (ww here), right? And is it a (easy) way to get it, since layout->parent() returns a QObject and not ww (probably because I did not create it as a child of ww)? or an easier way to constraint the thumbnails sizes?
w = new QWidget();
QHBoxLayout *LLayout = new QHBoxLayout();
w->setLayout(LLayout);
LLayout->addWidget(<some widget>);
QWidget *ww = new QWidget();
QVBoxLayout layout = new QVBoxLayout();
layout->setMargin(1);
layout->setSizeConstraint(QLayout::SetFixedSize);
ww->setLayout(layout);
layout->addWidget(<some widget>);
layout->addWidget(<some widget>);
layout->addWidget(<some widget>);
LLayout->addWidget(ww);
LLayout->setAlignment(ww, Qt::AlignTop);
printf("spacing=%d\n", layout->spacing());