Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    How to block object type QGraphicsView?

    General and Desktop
    2
    5
    1235
    Loading More Posts
    • 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
      maniek_1990 last edited by

      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 Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        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 Reply Quote 0
        • M
          maniek_1990 last edited by

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

          1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators last edited by

            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 Reply Quote 0
            • M
              maniek_1990 last edited by

              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 Reply Quote 0
              • First post
                Last post