Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10570

add a QGraphicsScene::focusItemChanged() signal

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P3: Somewhat important
    • 5.1.0
    • 4.6.2
    • Widgets: GraphicsView
    • None
    • Mac OS X 10.6.3, MacBook Pro, GCC4, Qt 4.6.2

    • I9cbbd9a2d15d6f568e1597c2c33ec049eb70f793

    Description

      I've placed some widgets in a QGraphicsView that allow for editing (e.g. QLineEdit, QTextEdit, or in my case some rich text editors based off QWebView). I also have a top level Edit menu with standard actions like Copy, Delete, Select All, etc. I'd like to be able to enable/disable these menu actions when the focus changes. Unfortuantely qApp->focusWidget returns a pointer to the QGraphicsView, not the widgets in the graphics scene, when the user clicks on one of these widgets. This isn't a problem since i can drill through the QGraphicsView to get at the embedded widget like so:

      QWidget* res = qApp->focusWidget();
      QGraphicsView* graphicsView = qobject_cast<QGraphicsView *>(res);
      QGraphicsScene* scene = graphicsView->scene();
      QGraphicsItem* focusItem = scene->focusItem();
      QGraphicsWidget* focusWidget = focusItem->topLevelWidget();
      QGraphicsProxyWidget* proxyWidget = qobject_cast<QGraphicsProxyWidget *>(focusWidget);
      QWidget* widget = proxyWidget->widget();

      here's the problem, I can only detect a focus even change occuring when the user clicks on the graphics view, not when an particular item in the view actually gets focus (by which I can detect using the above code). That said, this could be made slight better if a signal was added to QGraphicsScene:

      void QGraphicsScene::focusItemChanged() signal;

      A better solution would be for QApplication to notify me that a focus change has taken place when the user clicks on various editable widgets within the graphics view itself, thus making it unnecessary to manually connect to yet another signal on the fly when a graphics view gets focus.

      ...or is there a way to already do all this?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bibr Andreas Aardal Hanssen
            wstokes Will Stokes
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes