Important: Please read the Qt Code of Conduct -

[Solved]Creating Custom MessageBox

  • Dear all,

    I created the customized message box, like changing the color of text displayed,size of button,size if message window etc...

    How to make it as class so that i can access it similar to @#include <QMessageBox>@ like @#include<CustomMessageBox>@

    or can we change the font,size,color parameter of existing messageBox?

    Suggestions are welcome.

  • If you have created your custom message box, it should be already an class, isn't it?
    Just pack it into the header & source files and use it....

    <QMessageBox> is just an text file with reference to qmessagebox.h

    For example you have called your class CustomMessageBox and have header and source file like:
    custommessagebox.h & custommessagebox.cpp (maybe custommessagebox.ui to)
    just create simple text file CustomMessageBox without extension and add include in this file:

    file CustomMessageBox
    #include <custommessagebox.h>

    thats all...

    you can then include your CustomMessageBox file and use your class:
    #include <CustomMessageBox>

    CustomMessageBox box(...);
    box.exec(); //etc...

  • You can change colors, alignment, font's parameters and etc. via Qt style sheets...

  • yea dear AcerExtensa & AlekseyOk. tried both and both are working fine.thanks a lot.

Log in to reply