使用Qt在设置中存储码头寡妇布局和尺寸的任何简单方法吗? [英] Any easy way to store dock widows layout and sizes in settings with Qt?

查看:148
本文介绍了使用Qt在设置中存储码头寡妇布局和尺寸的任何简单方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有一些内部可停靠窗口的主窗口.我可以移动,调整大小和重新放置那些可停靠的窗口.关闭并重新打开程序后,我希望保持移动,大小和重新放置.有什么简单的实现方法吗?我认为它将使用设置.但是哪些信息应保存在设置中.以及如何为所有这些停靠窗口设置默认布局?单击操作按钮时,可以将其还原.谢谢.

I have a main window with some internal dockable windows. I can move, resize and redock those dockable windows. After close and reopen the program, I want the moves, sizes and redocking are kept. Any easy way to implement it? I think it will use settings. But which info should be saved in settings. And how to set a default layout of all these dock windows? When click an action button, it can be restored. Thanks.

推荐答案

不幸的是,不,没有内置的方法可以实现此目的.

Unfortunately, no, there is no built-in way to do this.

您需要遍历所有工具栏和可停靠的小部件,并将它们的位置(以及可能的可见性)写入文件.要还原,您可以读取该文件并根据所读取的内容设置位置.

You'll need to loop through all your toolbars and dockable widgets and write their positions (and possibly their visibility) to a file. To restore, you can read that file and set your positions based on what you read.

好消息是,一旦您建立了这样的系统,进行默认布局便很容易-将所有小部件移动到所需的位置,然后保存布局文件,就像执行上述用户布局一样.您甚至可以拥有多种布局,只要它们都获得单独的文件即可.

The good news is that once you have such a system set up, making a default layout is easy - move all your widgets where you want them, then save your layout file, just like you do the user layouts above. You can even have multiple layouts, as long as they all get separate files.

这篇关于使用Qt在设置中存储码头寡妇布局和尺寸的任何简单方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆