Originally Posted by
drkbkr
This may be a ridiculous question. And it may be just a C++ question. But I am totally lost here.
I would think that if I have declared an object, say a QListView, in a header file, but have not yet initialized that object, I could test for that declared but not initialized state with
if(sequenceList == NULL)
if(sequenceList == NULL)
To copy to clipboard, switch view to plain text mode
where sequenceList is the name of my QListView. But it is always returning false, whether initialized or not. I've also tried:
if(sequenceList == null)
if(sequenceList == null)
To copy to clipboard, switch view to plain text mode
and
if(sequenceList == 0)
if(sequenceList == 0)
To copy to clipboard, switch view to plain text mode
What am I doing wrong here? Any help would be greatly appreciated.
Thanks,
Derek
Depends on your compiler but pointers are rarely set to 0. You've got to do it in the constructor:
SomeClass::SomeClass(...)
: sequenceList(0)
{
//other stuff
}
SomeClass::SomeClass(...)
: sequenceList(0)
{
//other stuff
}
To copy to clipboard, switch view to plain text mode
which is the same as :
SomeClass::SomeClass(...)
{
sequenceList = 0;
//other stuff
}
SomeClass::SomeClass(...)
{
sequenceList = 0;
//other stuff
}
To copy to clipboard, switch view to plain text mode
Bookmarks