Results 1 to 15 of 15

Thread: Memory error for Qlabel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Posts
    116
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Memory error for Qlabel

    Hello All,


    I m using Qt 4.4.0

    I have below code

    Qt Code:
    1. //in Header file
    2. class C1
    3. {
    4. private:
    5. QLabel *img_label_1;
    6. QLabel *img_label_2;
    7.  
    8. QLabel *img_label_3;
    9. QLabel *img_label_4;
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //in CPP file
    2.  
    3.  
    4. C1::C1(QWidget * parent):QDialog(parent)
    5. {
    6. ui.setupUi(this);
    7. setWindowFlags( Qt::FramelessWindowHint);
    8.  
    9. img_label_4 = NULL;
    10. img_label_1 = NULL;
    11. img_label_2 = NULL;
    12. img_label_3 = NULL;
    13.  
    14.  
    15. if((img_label_1 = new QLabel(ui.frame)) != NULL)
    16. QMessageBox::information(this,"TRUE","");
    17. img_label_1->setPixmap(QPixmap(":/images/pink-1.png"));
    18. img_label_1->setGeometry(6,4,16,16);
    19. img_label_1->setScaledContents(TRUE);
    20. img_label_1->show();
    21.  
    22. img_label_1->setStyleSheet( "border-style:solid;\n"
    23. "border-color:rgb(86,86,86);\n"
    24. "border-width:1px;\n"
    25. );
    26. //In same way I m alloctiing 2 more labels
    27. //And now the turn of 4th label
    28.  
    29. if((img_label_4 = new QLabel(this)) != NULL)
    30. QMessageBox::information(this,"TRUE","");
    31.  
    32.  
    33. }
    To copy to clipboard, switch view to plain text mode 
    Now the problem is
    when I include
    Qt Code:
    1. if((img_label_4 = new QLabel(this)) != NULL)
    To copy to clipboard, switch view to plain text mode 
    statement
    after closing the EXE it gives Memory error

    If I comment the above line it doesnt giv any error..

    The drive where program resides has 1.2 G free memory.

    As soon as it allocates memory for 4th label ,it gives memory error after closing EXE.

    Please help
    Last edited by wysota; 4th April 2009 at 10:47. Reason: Changed [quote] to [code]

Similar Threads

  1. Memory debugging in windows
    By txandi in forum Qt Programming
    Replies: 3
    Last Post: 20th February 2009, 13:45
  2. memory leak question
    By cool_qt in forum General Programming
    Replies: 3
    Last Post: 20th January 2009, 07:49
  3. Memory management
    By cyberboy in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2008, 20:48
  4. Memory leak weirdness
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 10th January 2008, 18:51
  5. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42

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.