简体   繁体   English

自动调整qt应用程序的大小。 (主窗口)

[英]Auto resizing qt application. (main window)

I've recently started development in qt and so far it's going good. 我最近开始在qt中进行开发,到目前为止一切顺利。 Now my question is : can I auto re-size qt application as per my screen resolution ? 现在我的问题是:是否可以根据屏幕分辨率自动调整qt应用程序的大小? Say, I 've a main window designed for 1366 x 768. And it works for one system. 说,我有一个主窗口设计为1366 x768。它适用于一个系统。 While porting it to another system which supports 1280 x 800 or 800 x 600, is there an easy way to do it ? 将其移植到支持1280 x 800或800 x 600的另一个系统时,有没有简单的方法? without changing UI design in creator ? 无需在创作者中更改UI设计?

I appreciate any help regarding this. 我对此表示感谢。

Thanks in advance. 提前致谢。

Try do this (for example put it in the mainWindow's constructor) 尝试执行此操作(例如,将其放入mainWindow的构造函数中)

this->showMaximized();

Anyways you can simply get resolution of current screen with this code: 无论如何,您可以使用以下代码简单地获得当前屏幕的分辨率:

qDebug() << QApplication::desktop()->size();

And QWidget have resize() method. QWidget具有resize()方法。 QMainWindow inherits QWidget , so you can use resize() in your mainWindow. QMainWindow继承了QWidget ,因此您可以在mainWindow中使用resize()

Qt (and many other UI toolkit) solve auto resize problem with a layout manager, it depend on how do you design your UI to choose a layout or mix them. Qt(以及许多其他UI工具包)使用布局管理器解决了自动调整大小的问题,这取决于您如何设计UI来选择布局或混合它们。 See http://qt-project.org/doc/qt-4.8/layout.html 参见http://qt-project.org/doc/qt-4.8/layout.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM