Unable to have 2 QGraphicsView getting their own events
I have 1 main QGraphicsView, that has 2 QGraphicsView children. Each of the children has one custom QGraphicsTextItem.
When I double click on one of the QGraphicsTextItems (whatever the one I am clicking on), I can type letters and they appear properly in it.
When I then double click the other QGraphicsTextItem, the first one gets the double-click event and the letters.
If I restart my app and first click on the second QGraphicsTextItem, then the first one will never get focus.
How can I ensure that the one I am clicking on gets the events ?
That's the code in each of the QGraphicsView children:
Code:
myQGraphicsTextItemClass *oneTextNode
oneTextNode=new myQGraphicsTextItemClass(newNodeId,nodeName,this->geometry().width());
oneTextNode->setPos(10,30);
scene()->addItem(oneTextNode);
And the double click event of the QGraphicsTextItem:
Code:
{
setTextInteractionFlags(Qt::TextEditorInteraction);
}
and my class definition:
Code:
{
Q_OBJECT
public:
virtual ~myQGraphicsTextItemClass() {};
protected:
};
Thanks !
Re: Unable to have 2 QGraphicsView getting their own events
Quote:
Originally Posted by
EarthHobbit
I have 1 main QGraphicsView, that has 2 QGraphicsView children.
Why?
Cheers,
_
Re: Unable to have 2 QGraphicsView getting their own events
I am writing a node editor. Each node is represented by a QGraphicsView. I can potentially have 20 QGraphicsView children or more.
And the name of the node is displayed on it using a QGraphicsTextItem (must be editable).
Added after 10 minutes:
The issue is even actually the same with 2 QGraphicsTextItem in the same QGraphicsView.
Re: Unable to have 2 QGraphicsView getting their own events
Quote:
Originally Posted by
EarthHobbit
Each node is represented by a QGraphicsView.
Why?
Cheers,
_
Re: Unable to have 2 QGraphicsView getting their own events
It makes it easier to drag, as I use it as a placeholder for multiple elements.
Re: Unable to have 2 QGraphicsView getting their own events
What makes it easier to drag than a QGraphicsItem?
Re: Unable to have 2 QGraphicsView getting their own events
I don't know. Being new to Qt this what I did. Let me check the QGraphicsItem.