Important: Please read the Qt Code of Conduct -

[Split] Transparent Main Window

  • Mod note:
    thread split out of the original thread " to get an simple transparent window": 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 
    return a.exec();

    Does anybody know what i do wrong?

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

    I Solved this by

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

    This example shows another approach.

    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.

  • Hi Schneidi,
    thank you for your reaction!

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

    What exactly do you want to do ?
    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,

  • 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

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

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

  • thanks for splitting Volker!

  • 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. :(

Log in to reply