PDA

View Full Version : double QLabel declaration problem



Pawello
11th August 2012, 11:26
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


#include <QLabel>

class N : public QWidget
{
Q_OBJECT
public:
N(QWidget *parent = 0);
private:
QLabel *firstlabel;
QLabel *secondlabel;
}

Zlatomir
11th August 2012, 13:06
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.

Pawello
11th August 2012, 21:45
This problem appears even without using secondlabel in program, that's why it seems to be strange for me:/

ZikO
11th August 2012, 22:20
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.

spirit
12th August 2012, 09:12
This problem appears even without using secondlabel in program, that's why it seems to be strange for me:/
Show us cpp file.

Lykurg
12th August 2012, 15:45
Or even better: Just debug your application!

Pawello
13th August 2012, 10:57
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;)