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. Active QGraphicsScene on application startup
QtWS25 Last Chance

Active QGraphicsScene on application startup

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 383 Views
  • 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.
  • S Offline
    S Offline
    sirgienko.n
    wrote on last edited by
    #1

    Hi, I have an application, which contains QTabWidget with tabs. In this tab contains widget with two childrens: QGraphicScene widget with some QGraphicsTextItem inside and QGraphicView for this scene.
    So, it's very usfull have keyboard focus in the text element inside tab to starts enter text immideatly after application startup (like notepad: you run the app and you starts write text without using mouse to activate window).
    I could have this behavior with QPlainTextEdit in one of QTabWidget tabs: for this I set focus on the QPlainTextEditor.
    But for I can't do it for QGraphicItem, because I can't focus on this element, because scene of this element don't active. And as I see, scene don't active, because window don't active.
    So, could I active QGraphicsScene on startup?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Tried fast sample with
      https://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene.php
      and did
      ui->graphicsView->setFocus();
      rectangle->setSelected(true);

      and it does start up with view has focus and rectangle selected.

      Is that what you mean ?

      alt text

      test project
      https://www.dropbox.com/s/tc93kbi5w3c5and/GSceneTest.zip?dl=0

      S 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        Tried fast sample with
        https://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene.php
        and did
        ui->graphicsView->setFocus();
        rectangle->setSelected(true);

        and it does start up with view has focus and rectangle selected.

        Is that what you mean ?

        alt text

        test project
        https://www.dropbox.com/s/tc93kbi5w3c5and/GSceneTest.zip?dl=0

        S Offline
        S Offline
        sirgienko.n
        wrote on last edited by
        #3

        @mrjj Yes, almost: text graphic obejct instead of ractangle. But thanks for this suggestion, it's was very usefull, because I found problem.

        My problem was that I set focus on scene widget before adding the widget to tab widget. As I see, qt clear focus from the scene widget after adding to tab widget.

        I have added setting focus on scene after addTab statement and now it works.

        1 Reply Last reply
        1

        • Login

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