Results 1 to 2 of 2

Thread: Re: Newbie needs advice - QGraphics

  1. #1
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: Newbie needs advice - QGraphics

    {Forked from http://www.qtcentre.org/forum/f-newb...hics-7728.html}
    Qt Code:
    1. QGraphicsView *view = new QGraphicsView(this);
    2. QGraphicsScene *scene = new QGraphicsScene(view);
    3. scene->setSceneRect( 0, 0, 1000, 1000 ); //you can adjust this as you need
    4. view->setScene(scene);
    5. setCentralWidget(view);
    To copy to clipboard, switch view to plain text mode 
    Looking to your code, I remember the code piece in the Qt reference, which says:
    Qt Code:
    1. scene.addText("Hello, world!");
    2.  
    3. QGraphicsView view(&scene);
    4. view.show();
    To copy to clipboard, switch view to plain text mode 
    and I tryed this code, obtaining a well big exception, after a little modify:
    Qt Code:
    1. scene.addText("Hello, world!");
    2. ui.graphicsviewobj->setScene(&scene);
    To copy to clipboard, switch view to plain text mode 
    (ui object has been previously allocated)
    Instead of starting a new thread, I ask "why this" here, since I think it is fair in-topic...
    Last edited by jacek; 24th November 2007 at 18:10.
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie needs advice - QGraphics

    Haven't you forgot to ask the question?

    It seems that your problem is that you create the scene on the stack and it goes out of scope.

Similar Threads

  1. Newbie needs advice - QGraphics
    By Seth in forum Newbie
    Replies: 1
    Last Post: 26th June 2007, 06:12
  2. Newbie needs advice - QGraphicsLineItem
    By Seth in forum Newbie
    Replies: 4
    Last Post: 30th May 2007, 09:23
  3. Newbie needs advice
    By Seth in forum Newbie
    Replies: 3
    Last Post: 12th April 2007, 23:50
  4. Newbie needs advice on moving to designer
    By nbkhwjm in forum Newbie
    Replies: 2
    Last Post: 12th April 2007, 00:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.