Hello,
I want to use my own Button-Widget in a QGraphicsView. Adding and displaying the widget works fine. Unfortunately this Button has round corners which are not displayed transparent in the view tree. When I use the the same widget in a QMainWindow the outside areas are drawn transparent. The same effect occur by using a default Qt-Widget like QDial.
This code shows the widget with transparent behavior:
(I used QTextEdit just to get (quick and dirty) a white background)
int main(int argc, char *argv[])
{
pEdit->setGeometry(0,0,main.size().width(),main.size().height());
pDial->setGeometry(40,00,100,100);
main.show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow main;
QTextEdit * pEdit = new QTextEdit(&main);
QDial * pDial = new QDial(&main);
pEdit->setGeometry(0,0,main.size().width(),main.size().height());
pDial->setGeometry(40,00,100,100);
main.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
The following code shows the same widget in a QGraphicsView with opaque behavior:
int main(int argc, char *argv[])
{
scene.setBackgroundBrush(Qt::white);
QGraphicsProxyWidget * pWidget = scene.addWidget(pDial,Qt::Widget);
view.show();
return a.exec();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QGraphicsScene scene;
scene.setBackgroundBrush(Qt::white);
QDial * pDial = new QDial(NULL);
QGraphicsProxyWidget * pWidget = scene.addWidget(pDial,Qt::Widget);
QGraphicsView view(&scene);
view.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Can anyone give me a hint how to render the widget with transparent corners?
Thanks in advance!
Denis
Bookmarks