sebastian
sebastian

Reputation: 159

How to check that Qwidget exist

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();

}

Upvotes: 1

Views: 3696

Answers (3)

OliJG
OliJG

Reputation: 2720

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")

Upvotes: 1

PiedPiper
PiedPiper

Reputation: 5785

It looks like addLoginData is not initialised

Upvotes: 1

Georg Fritzsche
Georg Fritzsche

Reputation: 99122

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

MainWindow::MainWindow()
  : addLoginData()
  // ...
{
    // ...
}

Upvotes: 0

Related Questions