Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How to access scene in other class

    General and Desktop
    2
    3
    1755
    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.
    • S
      sri438 last edited by

      hi i got small problem i decleared scene in mainwindow i want to add rectitems in the scene in other class...i am accessing the scene but when i am adding items it was not showing any items...

      @

      m=new mainwindow();
      ...
      ...
      m->scene->addRect(100,10,100,20);
      m->scene->update();
      @
      i done like this that scene was not up dating....some one send solution pls

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        Are you sure the rect you added is in the visual area of your view? The code you post is close to useless. We cannot see what is actually happening based on these three lines.

        1 Reply Last reply Reply Quote 0
        • S
          sri438 last edited by

          mainwindow.cpp
          @
          scene=new QGraphicsScene(this);
          view=new QGraphicsView(this);
          view->setScene(scene);
          @
          one application is there i created in seperate class which is derived from QDilog....i created one buton in main window.. when i click on that button that dialog will open it contains some file reading thing in that file some rectitem co-ordinates are there...while i was reading the file i want to up date the scene with those rect coordinates.... now tell me how to add rectitem to the scene in that dialog class....is it possible to update the scene in different class??

          1 Reply Last reply Reply Quote 0
          • First post
            Last post