PDA

View Full Version : How to resize QWidget to be larger than screen?



qtcenter2019
27th March 2019, 16:53
Suppose the screen resolution is 800x600, resize(1000,1000) does not work. It will resize the widget to the size of the screen, i.e., 800x600. But resize(300,300) works.i.e., can resize the widget smaller than the screen.

So how to resize a widget to be larger than the screen?

d_stranz
27th March 2019, 20:18
Embed the QWidget inside of a QScrollArea and call QScrollArea::setWidgetResizable() with a "true" argument.

qtcentre2019
28th March 2019, 11:47
Thanks! I notice some widgets such as QWebEngineView can be larger than screen, so I wonder if there exists some function I can use to set a widget larger than screen as QWebEngineView is also a QWidget based class.

d_stranz
28th March 2019, 17:05
It might be possible with some widgets, but what is the point? If your widget is larger than the screen size, you can't see all of it so you will need to invent some way to scroll it around so you can see the parts that are off screen. That's the point of QScrollArea - it adds the UI controls needed for that.

If you simply want to display a smaller area of your widget full screen without scrolling support, then that's what QPainter viewports and transformations are used for.

pdpanchal115
29th March 2019, 10:33
widget->setGeometry(geometry())

it will set new geometry of widget.

qtcentre2019
1st April 2019, 18:20
I tested QWebEngineView and found it can not be larger than screen, either. I want to expand QWebEngineView to fit its content, which is larger than screen, in order to render full web page into an image. Using QScrollArea to contain QWebEngineView does not work; the QWebEngineView contained in it is still constrained to screen size. I'm curious if this size constraint is what Qt is designed for all platforms, or just for Windows, or it is a bug on my system. I do not think it has no point to have a window larger than screen because you can drag the window bar to see the hidden part of window.



It might be possible with some widgets, but what is the point? If your widget is larger than the screen size, you can't see all of it so you will need to invent some way to scroll it around so you can see the parts that are off screen. That's the point of QScrollArea - it adds the UI controls needed for that.

If you simply want to display a smaller area of your widget full screen without scrolling support, then that's what QPainter viewports and transformations are used for.


widget->setGeometry(geometry())

it will set new geometry of widget.

Unfortunately, setGeometry can not set a size larger than screen, either.

d_stranz
1st April 2019, 18:43
you can drag the window bar to see the hidden part of window.

Only if the window bar (or some other draggable part of the window) is visible on screen. If the window is 2x the size of the screen in both x and y, and you center it on screen, then there is nothing to grab to drag unless you implement it as part of the widget. It is the window system (Windows) that puts the title bar and other handles on windows so you can drag them.

qtcentre2019
2nd April 2019, 17:36
Only if the window bar (or some other draggable part of the window) is visible on screen. If the window is 2x the size of the screen in both x and y, and you center it on screen, then there is nothing to grab to drag unless you implement it as part of the widget. It is the window system (Windows) that puts the title bar and other handles on windows so you can drag them.

Yes, you are right. If the window bar is hidden also, it would be hard to drag the window. But I see many applications(maybe not developed using qt) have windows larger than screen, so it would not be the constraint of Windows. It could cause problem in some cases. In my case, I cannot figure out how to render the whole web page in QWebEngineView to an image.

anda_skoa
3rd April 2019, 09:03
Maybe QWebEngineView is setting a maximum size?

Usually widgets don't have such a restriction but since WebEngineView is sharing a buffer with the rendering process it might have.

Cheers,
_