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. How to block object type QGraphicsView?
QtWS25 Last Chance

How to block object type QGraphicsView?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.5k 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.
  • M Offline
    M Offline
    maniek_1990
    wrote on last edited by
    #1

    Hello All
    I wanna block object QGraphicsView that Nobody can click and do something on this window. Window has to be only to read.

    I used function:
    ui->GW_plansza->setInteractive(false);
    but this doesn't working
    Any Ideas?
    thanks for help and answers.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      easiest way would be to set it disabled

      Or you can try the following:
      @
      widget->setAttribute(Qt::WA_TransparentForMouseEvents, true);
      @

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maniek_1990
        wrote on last edited by
        #3

        your method doesn't working in my game :/
        I use object type QGraphicsView as board in game boats.

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          ok lets start from the beginning :)
          What do you exactly want to achieve?
          Let me know if i misunderstood something:

          • your window may be focusable, but no contents of it may be editable.
          • the window may be still resizeable and moveable
          • the window is a top level QGraphicsView?

          What does the QGraphicsView contain?
          What exactly doesn't work for you?
          When your graphics view contains editable items then setInteractive(false) should work. Also the disabling of the widget blocks input events for sure.

          Please show some more code if necessary.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maniek_1990
            wrote on last edited by
            #5

            this is part code which concerns object QGraphicsView in my program:

            @QGraphicsScene *scene = new QGraphicsScene(0,0,710,478);
            scene->setItemIndexMethod(QGraphicsScene::NoIndex);

                ui->GW_plansza->setScene(scene);
                ui->GW_plansza->setRenderHint(QPainter::Antialiasing);
                ui->GW_plansza->setBackgroundBrush(QPixmap("../Statki/images/plansza-final1.png"));
                ui->GW_plansza->setCacheMode(QGraphicsView::CacheBackground);
                ui->GW_plansza->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
                ui->GW_plansza->setDragMode(QGraphicsView::ScrollHandDrag);
                ui->GW_plansza->show();@
            

            Exactly I want stop settings and moving ships on new place.
            Program has to working how simple game in ships.
            Program has to working how simple game in ships. When first player will select points to shot, then second must have blocked window that he will can't nothing do.
            I am thinking that now explained better my problem :)

            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