Как установить начальный размер QScrollArea? ⇐ C++
Как установить начальный размер QScrollArea?
I want to display an image within a scroll area. The view port of the scroll area shall have a defined initial size. That means, if the image's size is bigger than the initial size of the view port, scroll bars will be visible, otherwise not.
// create label for displaying an image QImage image( ":/test.png" ); QLabel *label = new QLabel( this ); label->setPixmap( image.toPixmap() ); // put label into scroll area QScollArea *area = new QScrollArea( this ); area->setWidget( label ); // set the initial size of the view port // NOTE: This is what I'd like to do, but this method does not exist area->setViewPortSize( QSize( 300, 300 ) ); It shall be possible to resize the whole application so that the view port will get another size than the initial one.
Unfortunately, I was not able to find out, how to set the size of the view port. Qt's layout mechanism seems to set a default size for the view port, but up to now I was not able to change it.
Setting a new size with area->setMinimumSize( QSize( 300, 300 ) ); will actually set the demanded size, but then the scroll area looses the ability to get resized to a size smaller than 300x300.
Источник: https://stackoverflow.com/questions/241 ... scrollarea
I want to display an image within a scroll area. The view port of the scroll area shall have a defined initial size. That means, if the image's size is bigger than the initial size of the view port, scroll bars will be visible, otherwise not.
// create label for displaying an image QImage image( ":/test.png" ); QLabel *label = new QLabel( this ); label->setPixmap( image.toPixmap() ); // put label into scroll area QScollArea *area = new QScrollArea( this ); area->setWidget( label ); // set the initial size of the view port // NOTE: This is what I'd like to do, but this method does not exist area->setViewPortSize( QSize( 300, 300 ) ); It shall be possible to resize the whole application so that the view port will get another size than the initial one.
Unfortunately, I was not able to find out, how to set the size of the view port. Qt's layout mechanism seems to set a default size for the view port, but up to now I was not able to change it.
Setting a new size with area->setMinimumSize( QSize( 300, 300 ) ); will actually set the demanded size, but then the scroll area looses the ability to get resized to a size smaller than 300x300.
Источник: https://stackoverflow.com/questions/241 ... scrollarea
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
В Winui3, как мне ограничить начальный размер окна, чтобы оно не превышало размер дисплея?
Anonymous » » в форуме C++ - 0 Ответы
- 3 Просмотры
-
Последнее сообщение Anonymous
-
-
-
В Winui3, как мне ограничить начальный размер окна, чтобы оно не превышало размер дисплея?
Anonymous » » в форуме C++ - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-