tags:

views:

73

answers:

1
+1  Q: 

QPushButton Issues

Hi, 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);

alt text

+2  A: 

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.

jkerian
Thanks.If I used the stylesheet for button then only i got the rectangle. If I use the std button style then I am not getting the issue. Please help me.. I used the following code. secondclsss::secondclsss(QWidget *parent) : QWidget(parent){ QPushButton *first = new QPushButton("first"); first->setStyleSheet( "background-color:black;" ); QGridLayout *d = new QGridLayout(); d->addWidget(frist,0,0,1,1); setLayout(d); connect(first,SIGNAL(clicked()),this,SLOT(first()));}void secondclsss:: first(){ this->hide();}
Girija