I am finding a way to customize my window title bar for my PyQt4
application. As far as I understand, It is not possible to use Style-sheet
for this purpose. Instead I have to hide the title bar with
我正在找到一种方法来为我的PyQt4应用程序自定义窗口标题栏。据我所知,为此目的不能使用样式表。相反,我必须隐藏标题栏
.setWindowFlags(QtCore.Qt.FramelessWindowHint)
and implement my own title bar. This is where I am puzzled as I have seen someone did use a QHboxlayout
with QLabel
(for window title name) and QButton
(for exit,max,min actions) to make one like this
并实现我自己的标题栏。这是我感到困惑的地方,因为我看到有人确实使用QLboxlay和QLabel(用于窗口标题名称)和QButton(用于退出,最大,最小动作)来制作这样的一个
And he used Style-Sheets
to decorate each individual widgets. That's probably fine for a simple title bar. But what if I want more complicated title bar like this?
他使用Style-Sheets来装饰每个小部件。对于一个简单的标题栏来说,这可能很好。但是,如果我想要更复杂的标题栏呢?
I don't think just by altering Style-Sheets
properties will give me this kind of looks.
我不认为只是通过改变Style-Sheets属性会给我这种外观。
So,my question is, is it possible to create such a complicated title bar in PyQt4
? If so, as a beginner, what should I be looking at? I will dig and learn the concept by myself, I just needs some directions.
所以,我的问题是,是否有可能在PyQt4中创建这样一个复杂的标题栏?如果是这样,作为初学者,我应该注意什么?我将自己挖掘和学习这个概念,我只需要一些方向。
1 个解决方案
#1
0
Perhaps I am too late in replying, but anyway, I'll just let you know a few thing I have pickup myself. For one, it is quite easy to create such a "complicated" title bar, and UI using PyQt4. I would recommend you to read this post
也许我回答太迟了,但无论如何,我只会让你知道我自己拾取的一些东西。首先,使用PyQt4创建这样一个“复杂”的标题栏和UI非常容易。我建议你阅读这篇文章
Stacking QPushButtons on the other side of a QMenuBar
在QMenuBar的另一侧堆叠QPushButtons
The UI for the max/min/close buttons may be achieved using style sheets - you'll have to tinker with it a fair amount. If you have trouble adapting the code from Qt4 to PyQt4 you can mail me, I'll do my best to help you.
最大/最小/关闭按钮的UI可以使用样式表来实现 - 你必须修改相当数量。如果您无法将代码从Qt4调整到PyQt4,您可以给我发邮件,我会尽力帮助您。
#1
0
Perhaps I am too late in replying, but anyway, I'll just let you know a few thing I have pickup myself. For one, it is quite easy to create such a "complicated" title bar, and UI using PyQt4. I would recommend you to read this post
也许我回答太迟了,但无论如何,我只会让你知道我自己拾取的一些东西。首先,使用PyQt4创建这样一个“复杂”的标题栏和UI非常容易。我建议你阅读这篇文章
Stacking QPushButtons on the other side of a QMenuBar
在QMenuBar的另一侧堆叠QPushButtons
The UI for the max/min/close buttons may be achieved using style sheets - you'll have to tinker with it a fair amount. If you have trouble adapting the code from Qt4 to PyQt4 you can mail me, I'll do my best to help you.
最大/最小/关闭按钮的UI可以使用样式表来实现 - 你必须修改相当数量。如果您无法将代码从Qt4调整到PyQt4,您可以给我发邮件,我会尽力帮助您。