Results 1 to 3 of 3

Thread: What cannot be done in resizeEvent(..)?

  1. #1
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile What cannot be done in resizeEvent(..)?

    Hi, all,

    Detailed Description about my question:
    i created a panel widget (subclass of QWidget, (A)) to display some buttons. The count of buttons are dynamically changed in a slot called on_pageCount_changed(int), and this slot is connected with another object's (B) signal called pageCountChanged(int), and this signal is emitted when a resizeEvent happened to both the sender(B) and receiver(A) most of the time.

    Summary:
    That is to say, a behavior of delete/new children objects of object (A) is triggered by another object, B's signal, and this behavior might be triggered the same time when a resizeEvent happend to (A) or (both A and B).

    Some times crash happens (not every time) to
    "Unhandled exception at 0x65048e50 (QtGuid4.dll) in demo1120d.exe: 0xC0000005: Access violation reading location 0xfeeefefe."
    and if i delete the additional buttons next time the slot is called or if i just hide them, this error will not happen.

    so i am wondering if there is any limitation about what could be done when a resizeEvent happened, can objects be delete dynamically or not?

    Any help and suggestions will be greatly appreciately, thank you
    Last edited by nifei; 26th December 2008 at 02:01.

  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: What cannot be done in resizeEvent(..)?

    You cannot delete the signal sender in a slot because the control returns to the sender after connected slots have been processed. However, you can use QObject::deleteLater() instead.
    J-P Nurmi

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

    nifei (29th December 2008)

  4. #3
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Wink Re: What cannot be done in resizeEvent(..)?

    Quote Originally Posted by jpn View Post
    You cannot delete the signal sender in a slot because the control returns to the sender after connected slots have been processed. However, you can use QObject::deleteLater() instead.
    I donot think it is the deleting of signal sender in a slot that caused the crash, since the dynamically created and deleted buttons are not connected to any signals or slots. However, call QObject::deleteLater()instead indeed solved my problem. I think i misunderstand the order of deleting widgets and resizeEvent and showEvent / paintEvent. call deleteLater is safe here, but i still want to know why the crash happened, why the process call the objects that should have been deleted?

    Any way, thank jpn, your advice is really helpful.

Similar Threads

  1. resizeEvent help pls
    By munna in forum Newbie
    Replies: 10
    Last Post: 9th July 2010, 08:38
  2. Image on QLabel and resizeEvent
    By ^NyAw^ in forum Qt Programming
    Replies: 2
    Last Post: 12th September 2008, 09:32
  3. Reimplement of resizeEvent
    By Shawn in forum Qt Programming
    Replies: 20
    Last Post: 27th May 2007, 10:04
  4. resizeEvent from parent to child?
    By ChasW in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2007, 18:21
  5. Question about resizeEvent
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 28th February 2006, 16:13

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.