Results 1 to 3 of 3

Thread: QGraphicsScene and QGraphicsView

  1. #1
    Join Date
    Oct 2006
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question QGraphicsScene and QGraphicsView

    I could be missing something dreadfully obvious here, but....

    I have a plugin that creates a QGraphicsScene object and is attached to the QGraphicsView created in the main application. Through the plugin (from the context of the QGraphicsScene object), I want to create a QRadioButton that is attached to the underlying QGraphicsView.

    QList<QGraphicsView *>& Views = views();
    if(Views.size() == 0)
    {
    //safety code
    }
    //We can assume that the Scene (this) is connected to one and only one view.
    QRadioButton* pButton = new QRadioButton("Text", Views[0]);

    This does not compile on VS 2005 (Qt 4.2.1), the compiler complaining that QGraphicsView* and QWidget* are unrelated pointers. g++ on Mac whines similarily.

    According to the docs, the inheritance tree looks like:
    QGraphicsView <- QAbstractScrollArea <- QFrame <- QWidget

    According to my understanding of C++ this is an acceptable conversion.

    Is there something I'm missing, is the documentation correct or what?

    Ross

  2. #2
    Join Date
    Jan 2006
    Location
    Norway
    Posts
    124
    Thanked 38 Times in 30 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGraphicsScene and QGraphicsView

    Can you show the full source, please? At least including the function signature. :-)
    Bitto / Andreas Aardal Hanssen - andreas dot aardal dot hanssen at nokia
    Nokia Software Manager, Qt Development

  3. #3
    Join Date
    Oct 2006
    Posts
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Angry Re: QGraphicsScene and QGraphicsView

    Problem solved.

    Running the source through the preprocessor indicated that the QGraphicsView pointer was resolved through a forward reference in one of the header files. The compiler had no idea of the inheritance tree. As soon as I added:

    #include <QGraphicsView>

    to the source file, all was right with the world once again.

    Sorry for posting because of my sloppiness....

    We now return you to your regularily scheduled real problems.

    Ross

Similar Threads

  1. QGraphicsView, QGraphicsItem, QGraphicsScene
    By Shuchi Agrawal in forum Newbie
    Replies: 10
    Last Post: 23rd March 2011, 21:50
  2. How to make MDI editor with QGraphicsView support
    By Kuzemko in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 18:31
  3. QGraphicsScene and QThread
    By tts80 in forum Qt Programming
    Replies: 5
    Last Post: 10th January 2007, 10:32
  4. QGraphicsView and QGraphicsScene speeds
    By jnk5y in forum Qt Programming
    Replies: 2
    Last Post: 20th October 2006, 08:13
  5. (QT4.2-RC1) QGraphicsScene QGraphicsView QGraphicsItem
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 11:56

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.