I'm new to Qt, so I wonder whether there is a way to set the size of a QMainWindow
to (for example) 70% of the user's desktop.
I tried the stretch factor but it didn't work. QWidget::setFixedSize
worked but only with a pixel number, I think.
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- QT Layouts, how to make widgets in horizontal layo
- QT GUI freezes even though Im running in separate
- QGraphicsView / QGraphicsScene size matching
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- Why doesn't valgrind detect a memory leak in m
- QTreeView remove decoration/expand button for all
- Understanding the difference between Collection.is
- qt界面拥挤
You can use the
availableGeometry(QWidget*)
method inQDesktopWidget
, this will give you the geometry of the screen that this widget is currently on.For example:
Where
this
is the MainWindow pointer. This will work when using multiple screens.Somewhere in your QMainWindow constructor, do this:
resize(QDesktopWidget().availableGeometry(this).size() * 0.7);
This will resize the window to 70% of the available screen space.
Thanks to Amir eas. The problem is solved. Here's the code for it: