qt 设置串口起始位_【IT专家】Qt:如何设置主窗口的初始位置?
本文由我司收集整編,推薦下載,如有疑問(wèn),請(qǐng)與我司聯(lián)系
Qt
:如何設(shè)置主窗口的初始位置?
Qt
:如何設(shè)置主窗口的初始位置?
[
英
]Qt:
how
to
set
main
window’s
initial
position?
I
think
the
normally
window
manager
determines
the
initial
position
of
the
QMainWindow?position?on?the?desk?top.?I?want?to?set?the?initial?position?myself.?How?is
this?done?with?Qt?on?Windows?
我認(rèn)為通常的窗口管理器確定
QMainWindow
位置在桌面上的初始位置。我想自
己設(shè)定初始位置。如何在
Windows
上使用
Qt
完成此操作?
25
You?can?restore?the?window?geometry?with?restoreGeometry(),?and?the?state?of?docked
elements?with?restoreState(),?during?the?construction?of?your?MainWindow...
在構(gòu)建
MainWindow
期間,可以使用
restoreGeometry
()恢復(fù)窗口幾何,以及使
用
restoreState
()恢復(fù)停靠元素的狀態(tài)
...
QSettings
settings(“yourcompany”,
“yourapp”);
restoreGeometry(settings.value(“geometry”).toByteArray());
restoreState(settings.value(“state”).toByteArray(),YOUR_UI_VERSION);
Then,
if
you
override?closeEvent(),?you?can?save?the?state?as?follows:
然后,如果重寫
closeEvent
()
,則可以按如下方式保存狀態(tài):
QSettings
settings(“yourcompany”,
“yourapp”);
settings.setValue(“geometry”,
saveGeometry());
settings.setValue(“state”,
saveState(YOUR_UI_VERSION));
YOUR_UI_VERSION
is
a
constant
you
should
increment
when
your
UI
changes
significantly?to?prevent?attempts?to?restore?an?invalid?state.
YOUR_UI_VERSION
是一個(gè)常量,當(dāng)
UI
顯著變化時(shí),您應(yīng)該增加該常量,以防
止嘗試恢復(fù)無(wú)效狀態(tài)。
5
I?believe?you’re?looking?for?setGeometry.
我相信你正在尋找
setGeometry
。
總結(jié)
以上是生活随笔為你收集整理的qt 设置串口起始位_【IT专家】Qt:如何设置主窗口的初始位置?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 小新笔记本低温焊容易坏?联想回应:符合标
- 下一篇: webstorm 设置tslint_we