This is way harder than I expected!
I did a combination of Eventfilter and Focuschecking.
The Slot looks like this (where renameproxy is the QGraphicsProxyWidget of the LineEdit):
{
if (newFocusItem==renameproxy)
{
ui->graphicsView->removeEventFilter(filter);
}
else
{
ui->graphicsView->installEventFilter(filter);
}
}
void MainWindow::checkfocus(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)
{
if (newFocusItem==renameproxy)
{
ui->graphicsView->removeEventFilter(filter);
}
else
{
ui->graphicsView->installEventFilter(filter);
}
}
To copy to clipboard, switch view to plain text mode
and is connected to the Scene like so:
connect(scene,SIGNAL(focusItemChanged(QGraphicsItem*,QGraphicsItem*,Qt::FocusReason)),this,SLOT(checkfocus(QGraphicsItem *, QGraphicsItem *, Qt::FocusReason)));
To copy to clipboard, switch view to plain text mode
It would work to if I just had the LineEdit Widget. However now I cant move the selected Nodes around any more.
After around 3 h of experimenting and testing it's starting to get me frustrated.
One Possible solution I found would be to reimplement scrollContentsBy() of the GraphicsView. but this also means that I would have to handle draging the Scene around myself.
From all that experimenting my Code looks quite messy right now. After fixing this, and a break I probably will try to implement the dragscoll and post the result.
Bookmarks