PDA

View Full Version : QGraphicsProxyWidget background



Dgzt
23rd June 2012, 20:40
Hi!

I added a button to the QGraphics Scene:

QGraphicsProxyWidget *mCloseButton;
QPushButton *closeButton = new QPushButton( i18n( "Close" ) );
mCloseButton = scene()->addWidget( closeButton ); //Return QGraphicsProxyWidget

But around the button I have a gray rectangle.
( example: http://kepfeltoltes.hu/view/120623/pic_www.kepfeltoltes.hu_.png )

How can I set the background of QGraphicsProxyWidget (mCloseButton) so it can be equal with the background of QGraphicsScene.

wysota
23rd June 2012, 23:13
Call setAutoFillBackground(false) on the button.

Dgzt
23rd June 2012, 23:44
Call setAutoFillBackground(false) on the button.

No changing.

wysota
23rd June 2012, 23:58
Please show how you changed your code.

Dgzt
24th June 2012, 08:55
Please show how you changed your code.

I tried this:


QGraphicsProxyWidget *mCloseButton;
QPushButton *closeButton = new QPushButton( i18n( "Close" ) );
mCloseButton = scene()->addWidget( closeButton );

closeButton->setAutoFillBackground(false);


and this:



QGraphicsProxyWidget *mCloseButton;
QPushButton *closeButton = new QPushButton( i18n( "Close" ) );
mCloseButton = scene()->addWidget( closeButton );

mCloseButton->setAutoFillBackground(false);

wysota
24th June 2012, 10:02
You also need to set Qt::WA_NoSystemBackground attribute on the button.

Dgzt
24th June 2012, 11:07
You also need to set Qt::WA_NoSystemBackground attribute on the button.

Thanks, works. :)