Results 1 to 7 of 7

Thread: double QLabel declaration problem

  1. #1
    Join Date
    Jul 2012
    Posts
    25
    Thanks
    10

    Default double QLabel declaration problem

    Hi, I've found strange problem in my program.

    I can declare one Qlabel item, but declaring another one is connected with compilation error (file-build-desktop-....\debug\file.exe ends with code -1073741819 instead of 0).

    file.h
    Qt Code:
    1. #include <QLabel>
    2.  
    3. class N : public QWidget
    4. {
    5. Q_OBJECT
    6. public:
    7. N(QWidget *parent = 0);
    8. private:
    9. QLabel *firstlabel;
    10. QLabel *secondlabel;
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: double QLabel declaration problem

    That looks like access violation (segmentation fault), make sure you initialize the pointer secondlabel before you try to use it, or show us the code from the .cpp file if you need more help.

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

    Pawello (13th August 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    25
    Thanks
    10

    Default Re: double QLabel declaration problem

    This problem appears even without using secondlabel in program, that's why it seems to be strange for me:/

  5. #4
    Join Date
    Nov 2009
    Posts
    61
    Thanks
    9
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: double QLabel declaration problem

    I had the same error you indicated and it was when I forgot to initialize a pointer before using it. Sometimes this mistake happens to me when I add/remove lines and somehow remove the part where I did have a pointer initialized.

  6. The following user says thank you to ZikO for this useful post:

    Pawello (13th August 2012)

  7. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: double QLabel declaration problem

    Quote Originally Posted by Pawello View Post
    This problem appears even without using secondlabel in program, that's why it seems to be strange for me:/
    Show us cpp file.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. The following user says thank you to spirit for this useful post:

    Pawello (13th August 2012)

  9. #6
    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 Re: double QLabel declaration problem

    Or even better: Just debug your application!

  10. The following user says thank you to Lykurg for this useful post:

    Pawello (13th August 2012)

  11. #7
    Join Date
    Jul 2012
    Posts
    25
    Thanks
    10

    Default Re: double QLabel declaration problem

    As I said, problem appeared even without anything in cpp file. But I solved it. I made new identical project, copied code from all files and compliled it... and now it works. I don't understand it, but now it doesn't matter. Thanks for help

Similar Threads

  1. Program not finding an existing double in a QList<double>
    By aarelovich in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2011, 20:59
  2. QString to double convertion problem
    By NoRulez in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2010, 18:48
  3. Replies: 21
    Last Post: 3rd March 2010, 17:23
  4. Replies: 1
    Last Post: 29th September 2009, 19:44
  5. Replies: 4
    Last Post: 2nd January 2009, 06:27

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.