[Solved] how to make a QGraphicsProxyWidget modal
-
Dear all:
I am trying to create a QGraphicsProxyWidget that contain a QTable and a QPushButton. So far all is OK but I have a problem. I need the QGraphicsProxyWidget to block all the input to the QGraphicsScene when I said all the input I mean Mouse and Keyboard input except of course to the QGraphicsProxyWidget itselft.
Another problem is that I use a QVBoxLayout to layout the Widget inside the QGraphicsProxyWidget I am doing it like this:
@
// Create the Objects in the Dialog
channelSelectionList_ = new TraceOverlayChannelSelectionList(channels, targetChannelId);closeButton_ = new QPushButton(tr("&Finish")); connect(closeButton_, SIGNAL(clicked()), this, SLOT(finished_())); // Layout Objects QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(channelSelectionList_); layout->addWidget(closeButton_); setLayout(layout);
@
The problem is that for some reason the QTableView look to big with respect to the space that is need it. Is there a way to make the layout to compute the "real required space for the QTableView"?
Thanks a lot
Ernesto -
Hi,
Not really an answer but if you want to have all input blocked why not put your QTableView and its friends in a modal QDialog ?
-
Hi:
I thought that to the problem then is that to do so you need to pass a Parent to the QDialog since QGraphicsScene or QGraphicsItem are not real QWidget then they can't be parent, so you will need to pass one of the views of the QGraphicsScene. I have try that and it work but I find that is not really nice from the software design point of view. Thus why I thougth I can use a QGraphicsProxyWidget embedded in the scene.
All the best and thanks
Ernesto -
But the QGraphicsView is a widget so you can use it as parent
-
That is true but the problem is that a QGraphicsScene can be added in several QGraphicsView. So the question is how can the QGraphicsScene know what is the active view at that time? What I mean is the following:
Let supporse that the QGraphicsScene is added to 2 different views A and B. And that at the moment I am in View A, how do the QGraphicsScene know that is the view I am working at that moment?
All the best and thanks
Ernesto -
Any user events sent to the Scene and Items is always sent to the GraphicsView first. By reimplementing the events within QGraphicsView, or by adding an event filter, you can track which QGraphicsView is currently being worked on.
It then depends on your use case whether you react to the event directly within the QGraphicsView, or whether you keep the event logic in Scene and Items.
-
Thanks a lot for you advice I will keep the logic in the QGraphicsScene since it really does not depend on which view you are but is true that I can know who send the events so is really to do it in the way you propose.
Do you know how by chance how to solve the QTableView layout problem?
All the best and thanks
Ernest -
I would post the TableView problem as a separate post. The current title won't make TableView experts take a look. If you do so, please mark this post solved by adding '[Solved]' to the title (edit the first post to do that)