Results 1 to 4 of 4

Thread: Memory problems by creating several QDialogs

  1. #1
    Join Date
    Jun 2016
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Memory problems by creating several QDialogs

    Hi, at the moment I am working on a small game using Qt. It should stay quite simple, so I use QMainWindow for my main menu. From the menu you can open some QDialogs via pushButtons. I use the on_pushButton_clicked event to create a new object of the QDialog class and execute it.
    Because I want the dialogs to be modal, I show them with exec() and close them via close().
    To get no problems with the memory, I set the flag of every Dialog to Qt::WA_DeleteOnClose, to get sure to delete it. The problem is, everytime I close one, the program crashes.
    Without setting the flag, it works perfectly fine.
    Do you think its neccessary to delete them?

    Thanks for your help

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Memory problems by creating several QDialogs

    Maybe the dialog gets deleted twice?

    You could be creating the dialog instances on the stack of the slot, or have passed a parent that gets deleted before the dialog gets closed, etc.

    Cheers,
    _

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

    H31MD4L90 (8th June 2016)

  4. #3
    Join Date
    Jun 2016
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Memory problems by creating several QDialogs

    Currently *parent = 0 for all dialog classes I created.

    I just can´t estimate how much of memory I waste, if I don´t delete a closed dialog. Do you know whether this could bring some problems or not?
    Well, I know its at least not good style...
    Last edited by H31MD4L90; 8th June 2016 at 22:53.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Memory problems by creating several QDialogs

    Quote Originally Posted by H31MD4L90 View Post
    Currently *parent = 0 for all dialog classes I created.
    So you create the dialog with "new DialogClass" and have no delete anywhere?

    Quote Originally Posted by H31MD4L90 View Post
    I just can´t estimate how much of memory I waste, if I don´t delete a closed dialog. Do you know whether this could bring some problems or not?
    Well, I know its at least not good style...
    Sounds like a reasonable approach, but you seem to delete the dialog from to places

    Cheers,
    _

Similar Threads

  1. [QDirectFBScreen: error creating DirectFB interface]: Out of video memory!
    By Thành Viên Mới in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 10th February 2011, 05:44
  2. QDialogs are always on top - why?
    By Maximka in forum Newbie
    Replies: 4
    Last Post: 21st February 2010, 17:40
  3. Memory problems, please help!
    By Slewman in forum Qt Programming
    Replies: 1
    Last Post: 22nd October 2009, 20:14
  4. Check box creating problems
    By mat_me in forum Newbie
    Replies: 1
    Last Post: 1st May 2009, 10:20
  5. creating/deleting Objects // memory leaks
    By janus in forum Qt Programming
    Replies: 4
    Last Post: 27th March 2008, 19:17

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.