Results 1 to 3 of 3

Thread: Subclassing QGraphicsView crash the app

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Subclassing QGraphicsView crash the app

    Qt Code:
    1. fluxoCaixaGraphicsView::fluxoCaixaGraphicsView(QWidget *parent) :
    2. QGraphicsView(parent)
    3. {
    4. QGraphicsScene *cenario = new QGraphicsScene(this);
    5. }
    To copy to clipboard, switch view to plain text mode 
    you just declared a local variable named "cenario", it is not the same as your "cenario" in the header file
    change this to
    Qt Code:
    1. fluxoCaixaGraphicsView::fluxoCaixaGraphicsView(QWidget *parent) :
    2. QGraphicsView(parent)
    3. {
    4. this->cenario = new QGraphicsScene(this);
    5. }
    To copy to clipboard, switch view to plain text mode 
    btw. you should call base class implementation of the reimplemented event handlers.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,324
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Subclassing QGraphicsView crash the app

    Also need to insert the Q_OBJECT macro in the fluxoCaixaGraphicsView class definition:

    Qt Code:
    1. class fluxoCaixaGraphicsView : public QGraphicsView
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit fluxoCaixaGraphicsView(QWidget *parent = 0);
    7. ~fluxoCaixaGraphicsView();
    8.  
    9. // ...
    10. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGraphicsView crash... how to debug ?
    By pl01 in forum Newbie
    Replies: 3
    Last Post: 24th February 2011, 08:51
  2. Subclassing QNetworkReply
    By piotr.dobrogost in forum Qt Programming
    Replies: 6
    Last Post: 19th December 2010, 08:42
  3. Crash gracefully? No crash!
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2010, 03:59
  4. Subclassing QGraphicsView
    By sincnarf in forum Qt Programming
    Replies: 11
    Last Post: 27th August 2007, 19:36
  5. Subclassing
    By joseph in forum Newbie
    Replies: 1
    Last Post: 25th February 2006, 14:06

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.