Creating a widget on a QGraphicsView
Hi guys,
I would like to paint a transparent widget(with crossPattern) on the QGraphicsView. I create a widget with QGraphicsView as its' parent, but nothing happens. While moving on the view I can't move on the exact rectangle where I specify the widget, but I can't see it. What is more I do not want that to happend; the widget should not accept any focus etc.
Here is a piece of code,
Code:
panel
= new QWidget(m_view
);
//m_view is the QGraphicsViewpanel->setPaletteBackgroundColor(Qt::red);
panel->setFixedHeight(100);
panel->setFixedWidth(100);
panel->setBackgroundColor(Qt::red);
panel->setPaletteForegroundColor(Qt::red);
panel->setVisible(true);
panel->show();
How to make the widget visible?
How to force the widget to ignore any focus/mouseOver/mouseMove events?
Maverick
Re: Creating a widget on a QGraphicsView
Quote:
How to make the widget visible?
Since there isn't any layout to manage the widget's position and size, you have to do it manually, with move() or setGeometry().
You should move it in the desired position above the graphics view.
Quote:
How to force the widget to ignore any focus/mouseOver/mouseMove events?
Disable the widget. It won't receive any mouse or keyboard events.
Re: Creating a widget on a QGraphicsView
Hi,
Thanks for advice, but still I do not see my widget. There is 'something transparent" on or under the widget, but I do not see it.
Maverick
Re: Creating a widget on a QGraphicsView
You create the widget with the gv as parent. If you accidentally position this widget outside the bounds of the parent it will get clipped( you won't see it at all ).
So, double check you give the correct coordinates( try (0,0)).
Or, to make sure everything is ok with the widget and it can be seen, create it with a NULL parent and give it some position. It should appear at that position.
Regards
Re: Creating a widget on a QGraphicsView
Quote:
Originally Posted by
maverick_pol
Hi guys,
How to make the widget visible?
May be you should use m_view->viewport() as the parent of your widget.
Quote:
How to force the widget to ignore any focus/mouseOver/mouseMove events?
Maverick
You can follow Marcel's idea. You can also install event filter which ignores all the events so that you can have enabled look, yet ignore the events.