Results 1 to 2 of 2

Thread: can I get another QGraphicsView's scene?

  1. #1
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default can I get another QGraphicsView's scene?

    I want to print a QGraphicsScene's contents. How do I do this? The following code is wrong

    Qt Code:
    1. void MainWindow::print()
    2. {
    3. QPrinter printer;
    4. if (QPrintDialog(&printer).exec() == QDialog::Accepted) {
    5. QPainter painter(&printer);
    6. painter.setRenderHint(QPainter::Antialiasing);
    7. //QGraphicsScene scene = anotherQGraphicsView->scene();
    8. //What lines of code should I use to get another QGraphicsView's scene
    9. //No method like getScene() exists
    10. scene->render(&painter);
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: can I get another QGraphicsView's scene?

    I'm not exactly sure what's the problem. Provided that you have access to pointer anotherQGraphicsView, it's ... something like this?
    Qt Code:
    1. QGraphicsScene* scene = anotherQGraphicsView->scene();
    2. scene->render(&painter);
    To copy to clipboard, switch view to plain text mode 
    Or is the problem about how to access some graphics view/scen to which you don't have a pointer at hand?
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    sincnarf (4th October 2007)

Similar Threads

  1. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 20:50
  2. Deleting a scene from QGraphicsItem mouseEvent
    By JonathanForQT4 in forum Qt Programming
    Replies: 5
    Last Post: 10th April 2007, 11:27
  3. Scene focusing in QGraphicsView
    By mistertoony in forum Qt Programming
    Replies: 1
    Last Post: 9th March 2007, 16:34
  4. How to use QGraphicsView and Scene right ...
    By Mike in forum Qt Programming
    Replies: 6
    Last Post: 22nd January 2007, 08:51
  5. Replies: 1
    Last Post: 26th September 2006, 05:38

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.