【问题标题】:PySide: pyside-uic preview of stylesheet css is different from actual display in appPySide:样式表css的pyside-uic预览与app中实际显示不同
【发布时间】:2013-01-23 19:16:53
【问题描述】:

我在 Microsoft Windows Vista 的 Qt Designer(4.8.2) 中设计了一个 mainwindow.ui,在预览并满意结果后,我使用 pyside-uic 并得到了生成的 mainwindow.py。 但是当我运行我的应用程序时,显示与我在 Qt Designer 预览 中看到的不同,并且与 pyside-uic --preview 中的预览不同:: p>

我用来预览的:

pyside-uic mainwindow.py -p

我的应用的init

from PySide.QtGui import QApplication, QMainWindow
from mainwindow import Ui_MainWindow
import sys

class bookcalendar(Ui_MainWindow, QMainWindow):

    def __init__(self):

        super(bookcalendar, self).__init__()
        self.setupUi(self)

app = QApplication(sys.argv)
form = bookcalendar()
form.show()
app.exec_()

我看到运行 pyside-uic -p 脚本,

我看到的运行 .py 文件,

stackedWidget(parent)

--bookStack      <-     my style sheet css

--calendarStack      <-     my style sheet css

缺少灰色边框的css:

#bookStack{
    "border: 3px solid gray;
    "background-color: white;}

嗯,有什么建议吗?

【问题讨论】:

  • 嗯,我自己找到了答案。
  • 我所做的只是将 bookStack 上的 css 样式表剪切为 parent 上的 css 样式表,在我的例子中,stackedWidget。还要将规范编辑为stackedWidget,然后,所有的子栈看起来都一样。

标签: css qt pyside preview qwidget


【解决方案1】:

我找到了答案,解决方法是在父级中添加样式表css,如:

stackedWidget(parent)      <-     style sheet css

--bookStack

--calendarStack

做css样式表的正确方法:

#stackedWidget{
    "border: 3px solid gray;
    "background-color: white;}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-25
    • 2014-07-06
    • 2011-05-25
    • 2017-04-03
    • 2014-01-21
    相关资源
    最近更新 更多