How to make QMessageBox Transparent?
-
Hi,
I want an error messageBox to be transparent with respect to mainwindow .
i tried this code but dint work,please suggest.msgBox.setWindowModality(Qt::WindowModal);
msgBox.setStyleSheet("background-color:#0F1418;color:white;font-size:11pt");
msgBox.setVisible(true);
msgBox.show();thank you..
-
Your question is on a wrong forum, as the question is not in any way related to mobile or embedded systems.
Why should your color code be transparent - it is a fully opaque RGB code. You need to give an rgba code, with "a" less than 255.
(I don't know whether QMessageBox supports transparency - components may have restrictions - and running environments too... Which is why it is essential to state the OS) -
Hi
Do you really mean transparent ?
Like look through ? That would make the button sort of hover in the air and
look badly.You can color it as you like with style sheet
Also a note ,
you call msgBox.show();
so unless that is a test project and code is in main , it will run out of scope
and not even be shown. -
@kishore_hemmady
well you can use msgBox.setWindowOpacity(0.5); -
@mrjj
msg.setWindowOpacity(0.5);
msg.critical (0, "Error", "Improper XML, Load a proper XML!");
msg.exec();if i run this code first critical message will display first without opacity then
the message box will display with opacity without content in it -
@kishore_hemmady Because you show TWO message boxes!
http://doc.qt.io/qt-5/qmessagebox.html#critical is static! -
hi @jsulm
thank you,
how can I make critical message box as transparent?
As of now i am getting 2 message Box.One with critical error message and another with opacity without content in it -
@kishore_hemmady As I said you get two message boxes because you show one using static critical() method and then the second using show(). For critical() you actually don't need any object (that's why it is not opaque), you can call it via
QMessageBox::critical(...);
Your second message box is empty because you did not put anything in msg...
I don't think you can make message box opaque using critical().
You will need to set up your msg to show same contant as what critical() shows and removemsg.critical (0, "Error", "Improper XML, Load a proper XML!");