Results 1 to 5 of 5

Thread: QGraphicsView::resizeEvent(event)

  1. #1
    Join Date
    Feb 2007
    Posts
    39
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView::resizeEvent(event)

    while looking at some examples to fix a problem i've related with correct resizing of qgraphicscene inside a qgraphicsview i noticed this is commonly used by other people but when i use QGraphicsView::resizeEvent(event); inside my application i always get this error during compilation:

    Qt Code:
    1. void Myclass::resizeEvent( QResizeEvent *event )
    2. {
    3. QGraphicsView::resizeEvent(event);
    4. ......
    5. }
    To copy to clipboard, switch view to plain text mode 

    error C2248: 'QGraphicsView::resizeEvent' : cannot access protected member declared in class 'QGraphicsView'

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView::resizeEvent(event)

    Is Myclass a subclass of QGraphicsView?

  3. #3
    Join Date
    Feb 2007
    Posts
    39
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView::resizeEvent(event)

    No it isn't

    Also, same error if i do like this:

    Qt Code:
    1. void Myclass::resizeEvent( QResizeEvent *event )
    2. {
    3. myview->resizeEvent(event);
    4. ......
    5. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QGraphicsView::resizeEvent(event)

    Well, this is quite basic subject. You can't call a protected member from another class, unless it is a friend class or a subclass.

    Edit:

    So, you can do couple of things, for example:
    * subclass QGraphicsView and implement resizeEvent method
    * install eventFilter on QGraphicsView object and wait for event->type() == QEvent::Resize

    in both cases you can just call setSceneRect(QRectF) on your QGraphicsScene object
    Last edited by Rachol; 21st June 2011 at 12:44.

  5. The following user says thank you to Rachol for this useful post:

    Mrdata (21st June 2011)

  6. #5
    Join Date
    Feb 2007
    Posts
    39
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView::resizeEvent(event)

    i subclassed QGraphicsView and implemented resizeEvent, it works fine now Thanks

Similar Threads

  1. QGraphicsview and mouse press event
    By eva2002 in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2010, 05:04
  2. QGraphicsView, OpenGL widgets and event handling
    By Groovounet in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2010, 20:52
  3. Replies: 2
    Last Post: 24th October 2009, 23:45
  4. QGraphicsView Handling Child Event
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 9th August 2007, 00:32
  5. Replies: 3
    Last Post: 20th February 2007, 13:02

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.