Reputation: 8711
I am using the following code for create a button. It is working fine. but I got the yellow rectangle at the left corner. Why? Please help me. Thanks in advance,
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);
Upvotes: 2
Views: 2245
Reputation: 17016
I'm fairly sure the problem is not in the code you posted (unless, as cjhuitt mentions, it's in the background image). I snagged a simple background png off of google and tried the following 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_())
It produces the button without the odd little yellow box you're showing there.
Upvotes: 3