To show a message box I use this code:
int ret = QMessageBox::question(this,"Title","Stupid code",QMessageBox::Yes | QMessageBox::No);
Everything works as expected, but now, I want to remove the title bar of the message box. How can I achieve this?
I don't want to use:
QMessageBox msgBox("Title" , "Stupid code", QMessageBox::Question, QMessageBox::Yes | QMessageBox::No, this, Qt::FramelessWindowHint);
msgBox.exec();
I would suggest that you create a wrapper function by creating your own XMessageBox
class with a static member function question()
, accepting the same arguments as QMessageBox::question()
. In your wrapper function, create a QMessageBox
object with the arguments given to your function and in addition, the Qt::FramelessWindowHint
flag, call exec()
and pass on the return value. This way you only need to search and replace all occurrences of QMessageBox::question
with XMessageBox::question
in your code.
If you want more flexibility you can make your question()
function accept an additional argument of type Qt::WindowFlags
and pass this on to the QMessageBox
constructor.
The only alternative that will let you do what you want without changing any of your code would be to change the Qt code (qmessagebox.cpp) and recompile Qt.