[英]Removing titlebar from Qt window while keeping the default window borders
I'm trying to remove the default Windows titlebar from my Qt window (QT version 5.12.2 and using C++) while still keeping the window borders.我正在尝试从我的 Qt 窗口(QT 版本 5.12.2 并使用 C++)中删除默认的 Windows 标题栏,同时仍保留窗口边框。 I've more or less achieved this using the flag Qt::CustomizeWindowHint<\/code> .
我使用标志
Qt::CustomizeWindowHint<\/code>或多或少地实现了这一点。
However, this changes the window borders to white lines instead of the default borders.但是,这会将窗口边框更改为白线,而不是默认边框。
Example of how the borders look AFTER I've applied the
Qt::CustomizeWindowHint<\/code> flag:
应用
Qt::CustomizeWindowHint<\/code>标志后边框的外观示例:
<\/a>
As you can see, these are not the normal Windows window borders.如您所见,这些不是正常的 Windows 窗口边框。
Here's a minimal reproducible example:这是一个最小的可重现示例:
int main(int argc, char* argv[]) {
QApplication application(argc, argv);
launcher mainWindow;
//debugChecks();
mainWindow.setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::MSWindowsFixedSizeDialogHint);
mainWindow.setWindowTitle("Test");
mainWindow.show();
return application.exec();
}
QPalette and QStyle for Border
Your description isn't really clear.你的描述不是很清楚。 One should not be using a QMainWindow for a logon\/in dialog.不应将 QMainWindow 用于登录\/登录对话框。 Having said that I created an application on Ubuntu 20.04 (should build fine for you as I used qmake).话虽如此,我在 Ubuntu 20.04 上创建了一个应用程序(应该为您构建良好,因为我使用了 qmake)。 You can download the project zip here<\/a> .您可以在此处下载项目 zip<\/a> 。 When the application starts it looks like this:当应用程序启动时,它看起来像这样:
After clicking on "golden" it looks like this:点击“金色”后,它看起来像这样:
After Green it looks like this:在绿色之后它看起来像这样:
After clicking on Freaky it looks like this:单击 Freaky 后,它看起来像这样:
"You can do something like this你可以做这样的事情
self.setWindowTitle("") # Python
?
mainWindow.setWindowTitle(""); # C/C++
but instead of passing an empty string, pass an empty character.但不是传递一个空字符串,而是传递一个空字符。 This one worked for me: https://emptycharacter.com/这个对我有用: https ://emptycharacter.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.