Domanda

If I create my QDialog and show it modal with exec() everything works fine, but I need this no modal!

With show() the Dialog is empty!

ProgramLoading *programLoading = new ProgramLoading();  
programLoading->show(); 

// some code

programLoading->done(0);

Constructor

ProgramLoading::ProgramLoading(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);

    setWindowFlags( Qt::CustomizeWindowHint ); // remove window border
}

Don't think something with Dialog code is wrong because it works with exec()!

Any hints? Thank you!

PS: I'm using QT plugin for VisualStudio 2008

È stato utile?

Soluzione

mw (Default with Window Decoration):

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    sd = new SplashDialog();
    sd->show();

    QTimer::singleShot(10000,this,SLOT(closeSplashDialog()));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::closeSplashDialog()
{
    sd->close();
    delete sd;
}

splash (UI having Label and Button):

SplashDialog::SplashDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::SplashDialog)
{
    ui->setupUi(this);

    setWindowFlags( Qt::CustomizeWindowHint );
}

SplashDialog::~SplashDialog()
{
    delete ui;
}

Splash Dialog opens and is being closed 10 seconds later as intended

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top