How to access scene in other class



  • 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



  • 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.



  • 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??


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.