[solved] QTextEdit and QGraphicsProxyWidget - how to translate cursor coordinates?
-
wrote on 15 Oct 2011, 01:00 last edited by
I'm using a QTextEdit widget embedded in a QGraphicsScene with QGraphicsProxyWidget. I need to get the screen coordinates of the text cursor. If I do this with a non-embedded QTextEdit, I use something like:
@
cursorRect = QRect(textEdit->mapToGlobal(textEdit->cursorRect().topLeft()), textEdit->cursorRect().size());@How does one do this with an embedded QTextEdit widget?
TIA
-
wrote on 20 Oct 2011, 19:44 last edited by
This works:
QGraphicsProxyWidget *proxyWidget = textEdit->graphicsProxyWidget();
QGraphicsScene *graphicsScene = proxyWidget->scene();
QGraphicsView *graphicsView = graphicsScene->views().first();cursorRect = graphicsView->mapFromScene(proxyWidget->mapToScene(QRectF(textEdit->cursorRect()))).boundingRect();
cursorRect = QRect(graphicsView->mapToGlobal(cursorRect.topLeft()), cursorRect.size());
1/2