Results 1 to 6 of 6

Thread: [SOLVED] QLabel and Segmentation fault...

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default [SOLVED] QLabel and Segmentation fault...

    Hi,

    I have completely rebuild my project but get still a segmentation fault. I don't understand why, because the "setText()" works in the constructor but not in the function? Here is the relevant code:
    Qt Code:
    1. #include <QWidget>
    2. #include <QtGui>
    3.  
    4. class MyGraphicView : public QWidget
    5. {
    6. Q_OBJECT
    7.  
    8. public:
    9. MyGraphicView(QWidget *parent = 0);
    10.  
    11. private:
    12. void updateImageInformation();
    13.  
    14. QLabel *info_filesize;
    15. };
    16.  
    17.  
    18. //////////////////////// CPP-File ////////////////////////
    19.  
    20. #include "MyGraphicView.h"
    21.  
    22. #include <QtGui>
    23.  
    24. MyGraphicView::MyGraphicView(QWidget *parent) :
    25. QWidget(parent)
    26. {
    27. [...]
    28. info_filesize = new QLabel(this);
    29. [...]
    30. info_filesize->setText("KB"); // <- works!!!
    31. }
    32.  
    33. void MyGraphicView::updateImageInformation()
    34. {
    35. info_filesize->setText("----"); // <- SIGSEGV
    36. }
    To copy to clipboard, switch view to plain text mode 
    and GDB says:
    Qt Code:
    1. (gdb) run
    2. Starting program: /home/lykurg/workspace/cpp/workplace/ganesha/ganesha
    3. [Thread debugging using libthread_db enabled]
    4. [New Thread -1224829232 (LWP 9063)]
    5.  
    6. Program received signal SIGSEGV, Segmentation fault.
    7. [Switching to Thread -1224829232 (LWP 9063)]
    8. QLabel::setText (this=0x2f006c, text=@0xbf828400) at widgets/qlabel.h:154
    9. 154 widgets/qlabel.h: No such file or directory.
    10. in widgets/qlabel.h
    11. Current language: auto; currently c++
    To copy to clipboard, switch view to plain text mode 
    When I comment the "setText()" in updateImageInformation() out, the program starts and executes the constructor-setText without any problems.


    Thanks,

    Lykurg
    Last edited by Lykurg; 4th October 2007 at 13:03.

Similar Threads

  1. Replies: 2
    Last Post: 19th May 2007, 18:25
  2. segmentation fault insert QString in QCombobox
    By regix in forum Qt Programming
    Replies: 16
    Last Post: 8th August 2006, 08:46

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.