Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make QMessageBox Transparent?
Forum Updated to NodeBB v4.3 + New Features

How to make QMessageBox Transparent?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kishore_hemmady
    wrote on last edited by
    #1

    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..

    M 1 Reply Last reply
    0
    • K kishore_hemmady

      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..

      M Offline
      M Offline
      mvuori
      wrote on last edited by
      #2

      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)

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        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
        alt text

        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.

        K 1 Reply Last reply
        3
        • mrjjM mrjj

          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
          alt text

          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.

          K Offline
          K Offline
          kishore_hemmady
          wrote on last edited by kishore_hemmady
          #4

          hi @mrjj
          i need to have something like this.

          can i do this transparent messageBox ??

          mrjjM 1 Reply Last reply
          0
          • K kishore_hemmady

            hi @mrjj
            i need to have something like this.

            can i do this transparent messageBox ??

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @kishore_hemmady
            well you can use msgBox.setWindowOpacity(0.5);

            alt text

            1 Reply Last reply
            4
            • K Offline
              K Offline
              kishore_hemmady
              wrote on last edited by
              #6

              @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

              jsulmJ 1 Reply Last reply
              0
              • K kishore_hemmady

                @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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @kishore_hemmady Because you show TWO message boxes!
                http://doc.qt.io/qt-5/qmessagebox.html#critical is static!

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • K Offline
                  K Offline
                  kishore_hemmady
                  wrote on last edited by kishore_hemmady
                  #8

                  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

                  jsulmJ 1 Reply Last reply
                  0
                  • K kishore_hemmady

                    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

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @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 remove

                    msg.critical (0, "Error", "Improper XML, Load a proper XML!");
                    

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    K 1 Reply Last reply
                    4
                    • jsulmJ jsulm

                      @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 remove

                      msg.critical (0, "Error", "Improper XML, Load a proper XML!");
                      
                      K Offline
                      K Offline
                      kishore_hemmady
                      wrote on last edited by
                      #10

                      @jsulm
                      thank you @mrjj and @jsulm

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved