Hello!
In my software, in a given time, a pop-up window needs to be shown in order to send a message:
warningWindow->resize(200,100);
warningWindow->setWindowTitle("Alarm!");
warningWindow->setWindowFlags(Qt::Popup | Qt::WindowStaysOnTopHint);
warningWindow->setWindowState(Qt::WindowActive);
QLabel *alarm_titulo
= new QLabel("TIMETOUT!",warningWindow
);
alarm_titulo->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
alarm_titulo->resize(warningWindow->size());
alarm_titulo->show();
font.setPointSize(20);
alarm_titulo->setFont(font);
warningWindow->exec();
SAFEDELETE(warningWindow);
QDialog *warningWindow = new QDialog(this);
warningWindow->resize(200,100);
warningWindow->setWindowTitle("Alarm!");
warningWindow->setWindowFlags(Qt::Popup | Qt::WindowStaysOnTopHint);
warningWindow->setWindowState(Qt::WindowActive);
QLabel *alarm_titulo = new QLabel("TIMETOUT!",warningWindow);
alarm_titulo->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
alarm_titulo->resize(warningWindow->size());
alarm_titulo->show();
QFont font;
font.setPointSize(20);
alarm_titulo->setFont(font);
warningWindow->exec();
SAFEDELETE(warningWindow);
To copy to clipboard, switch view to plain text mode
As you can see, I want to make it a Popup style dialog (i.e. a dialog but without the typical window borders with the close button etc.). Since it will have no buttons to close it, I want warningWindow to close when the user clicks on it (or in its label alarm, which compress all of warningWindow's area). I know this has something to do with the mouseClickEvent, but once again I'm having trouble using this event handler thing from Qt (in my opinion mouse handling is still one of the worst things in Qt: everything could be much easier with simple signals!). How can I connect this click event with warningWindow's close() slot?
Thanks,
Momergil
Bookmarks