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. Translucent background - repaint issue Mac
Forum Updated to NodeBB v4.3 + New Features

Translucent background - repaint issue Mac

Scheduled Pinned Locked Moved General and Desktop
14 Posts 5 Posters 6.6k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    When a patch gets and added and removed it generally means that it breaks something while trying to fix something else

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Talei
      wrote on last edited by
      #5

      I suspected that it's the case in this situation.

      In general, as person that is new to MacOoX world, does it means that we cant get translucent background window?

      Maybe there is a wok around this? Native window?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #6

        Yes you can but your exact use case triggers that bug. One things you can do however is to add information on the current bug reports (also vote for it).

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Talei
          wrote on last edited by
          #7

          So how would I go about getting translucent background for widget in Qt on Mac?

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #8

            You already are using it, but why did you disable the background auto fill ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • T Offline
              T Offline
              Talei
              wrote on last edited by
              #9

              For TransWidget it was for testing - don't change anything

              On qlabel - I want only text no bg from QLabel, but that doesn't change the fat that if autoFill is true then rectangle is "left behind" and when false actual text.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                sandy.martel
                wrote on last edited by
                #10

                I the same problem on Mac when moving from Qt4 to Qt5. I could reproduce it with different projects or code examples. I fixed it by adding this code to my application:

                @
                void MyTransparentWindow::paintEvent( QPaintEvent * /event/ )
                {
                QPainter p( this );

                // Qt5 fail to give us a clear backbuffer...
                p.setCompositionMode( QPainter::CompositionMode_Clear );
                p.fillRect( 0, 0, width(), height(), QColor( 0, 0, 0, 0 ) );
                p.setCompositionMode( QPainter::CompositionMode_SourceOver );
                // end
                

                ...
                }
                @

                This fixed the problem for me when using Qt5.1.1, I haven't check if it's actually fixed in Qt5.2+.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Talei
                  wrote on last edited by
                  #11

                  sandy.martel
                  THANK YOU

                  I experimented earlier with fill Qt::transparent but without composition mode. Setting (only)

                  @
                  void TransWidget::paintEvent( QPaintEvent * /event/ )
                  {
                  QPainter p( this );

                  p.setCompositionMode( QPainter::CompositionMode_Clear );
                  p.fillRect( this->rect(), Qt::transparent );
                  

                  }
                  @

                  resolves problem:

                  Qt 5.2.1 - MacOSX 10.9.2

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #12

                    Very nice trick !

                    Thanks for sharing :)

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      JakeW
                      wrote on last edited by
                      #13

                      Thanks a lot for the trick, it works for me!

                      1 Reply Last reply
                      0
                      • DzybbaD Offline
                        DzybbaD Offline
                        Dzybba
                        wrote on last edited by
                        #14

                        This topic is old, but i face with same problem and tricks won't help me. Im using Qt 5.5
                        So i found solution in Telegram app source code.

                        1. Set attributes and window flags
                          m_widget->setWindowFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint | Qt::Tool | Qt::NoDropShadowWindowHint);
                          m_widget->setAttribute(Qt::WA_NoSystemBackground, true);
                          m_widget->setAttribute(Qt::WA_TranslucentBackground, true);
                        2. In paint event
                          QPainter::CompositionMode m = painter.compositionMode();
                          painter.setCompositionMode(QPainter::CompositionMode_Source);
                          painter.setOpacity(0.4);
                          painter.fillRect(w->rect(), Qt::black);
                          painter.setCompositionMode(m);
                        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