我使用下面的代码来创建一个按钮。它工作得很好。但是我在左边的角落看到了黄色的矩形。为什么?请帮帮我。提前谢谢你,
backButton = new QPushButton(tr("Back"));
connect(backButton, SIGNAL(clicked()), this, SLOT(showSearchResultPage()));
backButton->setStyleSheet(
"background-image: url(/Users/aspire/IPhone Development/background_wood_Default.png);"
"border-style: outset;"
"border-width: 2px;"
"border-radius: 10px;"
"border-color: beige;"
"font: bold 16px;"
"color:black;"
"min-width: 10em;"
"min-height: 0.75em;"
" margin: 0 1px 0 1px;"
"color:rgb(255,246,143);"
"padding: 6px;"
);
QGridLayout *layout = new QGridLayout();
layout->addWidget(backButton, 1, 0, 1, 1);
layout->addWidget(detailView, 2, 0, 1, 1);

发布于 2010-10-06 00:23:24
我非常确定问题不在您发布的代码中(除非,正如cjhuitt所提到的,它在背景图像中)。我从google上抓取了一个简单的后台png,并尝试了下面的python:
from PyQt4 import QtCore, QtGui
import sys
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
button = QtGui.QPushButton("Back")
button.setStyleSheet(
"background-image: url(wood.png);"
"border-style: outset;"
"border-width: 2px;"
"border-radius: 10px;"
"border-color: beige;"
"font: bold 16px;"
"color: black;"
"min-width: 10em;"
"min-height: 0.75em;"
"margin: 0 1px 0 1px;"
"color:rgb(255,245,143);"
"padding: 6px;"
)
grid = QtGui.QGridLayout(widget)
grid.addWidget(button,1,0,1,1)
widget.show()
sys.exit(app.exec_())它生成的按钮没有您在那里显示的奇怪的黄色小方框。
https://stackoverflow.com/questions/3862478
复制相似问题