Create frameless QMessageBox
-
I have an application which is constructed as a stackwidget. When the user presses a button, a QMessageBox will pop up. I would like to take off the title of the messagebox. However, when the button is pressed, the messagebox appears BUT the application closes. What do I need to change?
void user_Data::onClickButton() { QMessageBox *mb; mb->setWindowFlags(Qt::FramelessWindowHint |Qt::WindowStaysOnTopHint); mb->question(this,tr("TITLE"),tr("Are you sure you want to do this?")); }
-
Hi,
Two options:
- Allocate mb on the stack
- Initialize mb properly (don't forget to delete it when you're done using it.)
Warning: question is a static method, so currently you're using it wrongly.
-
Hi,
Two options:
- Allocate mb on the stack
- Initialize mb properly (don't forget to delete it when you're done using it.)
Warning: question is a static method, so currently you're using it wrongly.
@SGaist I am not sure I follow you. How would I initialize mb properly? Oops, yes it is a warning.
-
Well: you have to allocate it since you're declaring a pointer to it.
-
@SGaist Ok so the Application doesn't close anymore but the QMessageBox keeps showing the title bar.
-
Again: question is a static method, it won't make use of any of your settings.
Take a look at the Property based API chapter of QMessageBox documentation.