有没有一种简单的方法可以恢复 Qt 中的小部件大小?
我正在寻找一种在 Qt 应用程序中保留窗口大小的方法。
我已经看到可以对每个小部件使用以下方法:
saveGeometry()
但实际上,我不认为这是一种令人满意的方法。 有类似 setAutosaveGeometry(True)
的东西吗?
我特别寻找一种存储表列宽度的方法。
I'm looking for a way to preserve the size of windows in a Qt app.
I've seen that there is the possibility of using the following method for every widget:
saveGeometry()
But really, I don't find this a satisfactioning method. Is there something like setAutosaveGeometry(True)
?
I'm especially looking for a way to store the widths of table columns.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
QHeaderView 类还有两种方法用于在 QByteArray 中保存和恢复其状态:saveState()和restoreState()
表视图的标题可以通过horizontalHeader()和verticalHeader()方法访问。
The QHeaderView class also has two methods for saving and restoring it's state to and from a QByteArray: saveState()and restoreState()
A table view's headers are accessible via the horizontalHeader() and verticalHeader() methods.
saveGeometry 返回一个 QByteArray 值,您需要将其存储在某个地方。
示例:
要读取几何图形,请调用restoreGeometry函数:
要了解有关窗口几何图形的更多信息,请阅读文档< /a>
saveGeometry returns a QByteArray value, you need to store it somewhere.
Example:
For reading the geometry call the restoreGeometry function:
To learn more about window geometry please read the documentation
请参阅有关恢复窗口几何图形。
See the Qt documentation on Restoring a Window's Geometry.