Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] QTextEdit and QGraphicsProxyWidget - how to translate cursor coordinates?

[solved] QTextEdit and QGraphicsProxyWidget - how to translate cursor coordinates?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CuteiOS
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      CuteiOS
      wrote on last edited by
      #2

      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 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved