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. [Split] Transparent Main Window
QtWS25 Last Chance

[Split] Transparent Main Window

Scheduled Pinned Locked Moved General and Desktop
8 Posts 2 Posters 3.7k Views
  • 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.
  • V Offline
    V Offline
    vinb
    wrote on last edited by
    #1

    Mod note:
    thread split out of the original thread " to get an simple transparent window":http://developer.qt.nokia.com/forums/viewthread/1107/. The original problem was solved and this evolves to a thread of its own, Volker

    I have a question about this thread:

    When i try to make a (main)widget transparant, it doesnt seem to work, Transparant becomes black.
    @
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    Widget w;
    w.setStyleSheet("background:transparant;");  // output a black background
    w.setStyleSheet("background:purple;"); //output a purple background 
    w.setAttribute(Qt::WA_TranslucentBackground);
    w.show();
    
    return a.exec();
    

    }@
    Does anybody know what i do wrong?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Schneidi
      wrote on last edited by
      #2

      Hey vinb I had the same problem those days.
      But I can't remember what the reason ist.

      I Solved this by
      @
      setWindowFlags(Qt::FramelessWindowHint);
      @

      I did this because I implemented a specific chrome.
      What exactly do you want to do ?

      This example shows another approach.
      http://doc.qt.nokia.com/latest/widgets-shapedclock.html

      This example is using QPixmap::mask () to paint a widget with alpha channel information.
      I didn't get this to work yet, but maybe you will.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vinb
        wrote on last edited by
        #3

        Hi Schneidi,
        thank you for your reaction!

        Your first suggestion don't work for me, altough i get a frameless window. :)

        [quote]
        What exactly do you want to do ?
        [/quote]
        I want to create an invisible aplication on top of the desktop, with only the widget on top of the aplication visible.
        For all that matters: im working on a linuxbox (ubuntu).

        I'll try to get your second sugestion work for me and post the outcome if it works,
        But what i understand from it now is:

        1. you 'copy' the background to a pixmap and you show that pixmap, what is identical as the background. (like screenshot).
        2. on top of that pixmap you place widgets so it seems that the widgets are floating on top of the desktop.

        Is my assumption right?

        When its right, then i dont understand why the 'normal' aproach dont work, in other words.

        • What makes the desktop different then for example the mainwindow/widget, as the transparantie from a widget on top of the mainwidget does work?
        • And why does the transparantie statement becomes black?

        Thank in advance,
        Vincent

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #4

          I got the clock working (it was written for a phone and not a desktop), but i still dont understand why the 'normal' approach dont seem to work.

          If you want, i post the code for the desktop

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Schneidi
            wrote on last edited by
            #5

            I can't really remember what this problem cause.
            I guess I has something to do with the different layer that Qt handles.
            Esspecially the different widget layer. As long as I used the default chrome
            I didn't figure out how to set the basic mainWidget background layer to transparent.

            Maybe it has to do with the framebuffer operations.
            But this is just a guess.

            Is the approach of the clock example handy for your case or do you need the 'normal' way for any reason ?

            I would be interessted in get an idea about this too.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vinb
              wrote on last edited by
              #6

              At this moment, even the first code i write down here doesnt do the trick anymore :(

              About the clock:
              my first assumption was not right, it doesnt 'copy' the background.
              i think its been done by this line:
              @
              w.setWindowFlags(Qt::WindowSystemMenuHint);
              @
              but when i try that i dont see anything anymore not even the aplication icon, but the program is running.

              But i keep on trying and let you know if i managed to figure out what is the problem.

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vinb
                wrote on last edited by
                #7

                thanks for splitting Volker!

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vinb
                  wrote on last edited by
                  #8

                  Edit findings:

                  I noticed that the "invisibility" from the Shapedclock is not what i suspected
                  It doesnt make the widget transparant but it makes it an Ellipse.

                  So i stil havent found the solution yet. :(

                  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