Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

请教关于Qmainwindow的布局问题 #316

Open
wuyedefeng9 opened this issue Nov 9, 2023 · 4 comments
Open

请教关于Qmainwindow的布局问题 #316

wuyedefeng9 opened this issue Nov 9, 2023 · 4 comments

Comments

@wuyedefeng9
Copy link

Qt的Qmainwindow或者Qwidget有默认的布局,任何子类的控件会默认绘制在标题栏下方。但是我自定义的类,无论是继承于QObject或者Qwidget,假如设置为无边框并且使用了布局,设置了centerwidget,但子类的控件默认的绘制位置依然在左顶角,如何实现Qmainwindow或者Qwidget的效果?

@wangwenx190
Copy link
Owner

去掉系统边框后你自己组织内部的控件就行了,包括标题栏。但如果你设置了central widget,那么确实只能从左上角开始绘制,这个是QMainWindow内部固定的逻辑。要不你就别设置central widget,或者把你所有控件都放到一个central widget里

@wuyedefeng9
Copy link
Author

其实我想达到的效果就是QMainWindow的效果,只要是继承了自定义的无边框类,无论我自己如何构造子类,控件绘制都是从自定义的无边框类标题栏下方开始绘制

@wangwenx190
Copy link
Owner

QMainWindow有什么功能是你必须要用的?dock 停靠?

@wangwenx190
Copy link
Owner

如果你不需要dock功能,你完全可以自己用布局模拟一个QMainWindow出来

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants