1

Like in title how to check that child class from QWidget exist?

when i try something like that it break application end throw error

void MainWindow::slotAddLoginData() {
    if(!addLoginData) {
        addLoginData = new AddLoginData(this);
        connect(this, SIGNAL(setEnabledALDbtnOK(bool)),
        addLoginData, SLOT(btnOkEnabled(bool)));

    }
    addLoginData->show();
    addLoginData->activateWindow();

}
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
sebastian
  • 149
  • 1
  • 4
  • 13

3 Answers3

1

It looks like addLoginData is not initialised

PiedPiper
  • 5,735
  • 1
  • 30
  • 40
1

As others have said, addLoginData isn't initialized. You can't do this:

if(!addLoginData) { ... }

Unless you initialize addLoginData to 0. So, as Georg said, initialize it, except make that..

MainWindow::MainWindow() : addLoginData(0)

(note the "0")

OliJG
  • 2,650
  • 1
  • 16
  • 15
  • `addLoginData()` and `addLoginData(0)` do exactly the same thing here - default initialization means zero initialization in case of scalar types... See e.g. [here](http://stackoverflow.com/questions/936999/what-is-the-default-constructor-for-c-pointer). – Georg Fritzsche Dec 20 '10 at 14:03
0

One possibility would be that you have not initialized addLoginData. Use something like this in that case:

MainWindow::MainWindow()
  : addLoginData()
  // ...
{
    // ...
}
Georg Fritzsche
  • 97,545
  • 26
  • 194
  • 236