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. Transparent Buttons
Forum Updated to NodeBB v4.3 + New Features

Transparent Buttons

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 7.0k 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.
  • mstothM Offline
    mstothM Offline
    mstoth
    wrote on last edited by
    #1

    On Ubuntu 16.04 Using Qt Creator 4.0.3 Based on Qt 5.7.0 I create a transparent button as follows:

    darkButton = new QPushButton(this);
    darkButton->setText("");
    darkButton->setStyleSheet("QPushButton{background:transparent;}");
    darkButton->setGeometry(350,10,121,171);
    darkButton->show();
    connect(darkButton,SIGNAL(released()),this,SLOT(on_darkButton_released()));
    

    This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.

    Looking through the posts I have tried the following

    darkButton->setStyleSheet("background:transparent;")
    

    and

    darkButton->setAttribute(Qt::WA_NoSystemBackground, true)
    

    and

    darkButton->setAttribute(Qt::WA_NoBackground);
    darkButton->setAttribute(Qt::WA_NoSystemBackground);
    darkButton->setAttribute(Qt::WA_TranslucentBackground);
    
    

    but all of them still come up non-transparent.
    Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent?

    JonBJ JKSHJ 2 Replies Last reply
    0
    • mstothM mstoth

      On Ubuntu 16.04 Using Qt Creator 4.0.3 Based on Qt 5.7.0 I create a transparent button as follows:

      darkButton = new QPushButton(this);
      darkButton->setText("");
      darkButton->setStyleSheet("QPushButton{background:transparent;}");
      darkButton->setGeometry(350,10,121,171);
      darkButton->show();
      connect(darkButton,SIGNAL(released()),this,SLOT(on_darkButton_released()));
      

      This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.

      Looking through the posts I have tried the following

      darkButton->setStyleSheet("background:transparent;")
      

      and

      darkButton->setAttribute(Qt::WA_NoSystemBackground, true)
      

      and

      darkButton->setAttribute(Qt::WA_NoBackground);
      darkButton->setAttribute(Qt::WA_NoSystemBackground);
      darkButton->setAttribute(Qt::WA_TranslucentBackground);
      
      

      but all of them still come up non-transparent.
      Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @mstoth
      Please excuse my ignorance, but I am intrigued.

      Qt Creator lets you write C++ code. The code gets compiled and linked against a version of Qt, which in itself has nothing to do with the Creator. The effect of you writing the C++ code cannot vary depending on which Qt Creator you happened to create the source file in?

      1 Reply Last reply
      3
      • mstothM mstoth

        On Ubuntu 16.04 Using Qt Creator 4.0.3 Based on Qt 5.7.0 I create a transparent button as follows:

        darkButton = new QPushButton(this);
        darkButton->setText("");
        darkButton->setStyleSheet("QPushButton{background:transparent;}");
        darkButton->setGeometry(350,10,121,171);
        darkButton->show();
        connect(darkButton,SIGNAL(released()),this,SLOT(on_darkButton_released()));
        

        This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.

        Looking through the posts I have tried the following

        darkButton->setStyleSheet("background:transparent;")
        

        and

        darkButton->setAttribute(Qt::WA_NoSystemBackground, true)
        

        and

        darkButton->setAttribute(Qt::WA_NoBackground);
        darkButton->setAttribute(Qt::WA_NoSystemBackground);
        darkButton->setAttribute(Qt::WA_TranslucentBackground);
        
        

        but all of them still come up non-transparent.
        Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent?

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @mstoth said in Transparent Buttons:

        Using Qt Creator 4.0.3 Based on Qt 5.7.0

        The line above...

        • ...tells us what version of Qt was used to build your IDE.
        • ...does not tell us what version of Qt you using to build your project.

        See Tools > Options... > Build & Run > Kits instead. What version(s) of Qt are available on your machine?

        Note the difference between Qt (the library) and Qt Creator (the IDE)

        This works fine however on the same Ubuntu release with Qt Creator 4.0.2 the button comes up black instead of transparent.

        1. Same machine or different machine?
        2. Physical machine or virtual machine?

        Hard to believe that this is due to 4.0.2 vs 4.0.3! Could there be something else that is causing the button to be non-transparent?

        It's plausible that an older version of Qt had a bug that was fixed in a newer version.

        In fact, Qt 5.7 is quite old now. Try again with the latest Qt 5.9.2 from https://www1.qt.io/download-open-source/ (it also contains Qt Creator 4.4.1)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        4
        • G Offline
          G Offline
          Gugge
          wrote on last edited by
          #4

          Setting a style sheet for buttons might not work unless you check the button property "flat"

          G 1 Reply Last reply
          1
          • G Gugge

            Setting a style sheet for buttons might not work unless you check the button property "flat"

            G Offline
            G Offline
            GennerCarrillo
            wrote on last edited by
            #5

            @Gugge Thank you! you saved me.

            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