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. [Solved] Transparent Window

[Solved] Transparent Window

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.3k 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.
  • F Offline
    F Offline
    fatih.aslantas
    wrote on last edited by
    #1

    Hi all,

    i m new on QT and i m trying to develop a launcher. i set a transparent image at background but as u can see on this link ( http://prntscr.com/2a3qpz ), a black frame is surround my image. I researched on many websites, but i couldn't get anything about that.

    transparent image http://prntscr.com/2a3qw6

    i ve something which set background image, it works but not enough for my project. how can i delete this black frame? Can someone help me please?

    @ QPalette* palette = new QPalette();
    palette->setBrush(QPalette::Background,(new QBrush((new
    QPixmap(":/new/MyResources/launcher.png")))));
    setPalette(*palette);
    setWindowFlags(Qt::FramelessWindowHint);@

    Thank You

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      There is also a transparency setting for Windows. Maybe that is the issue?

      Greetz, Jeroen

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fatih.aslantas
        wrote on last edited by
        #3

        thank u for your post

        i ve try many things like
        @ setStyleSheet("background:transparent");
        setAttribute(Qt::WA_TranslucentBackground,true);
        @
        for example if i put this two codes nothing shows, i m missing some point :S

        1 Reply Last reply
        0
        • A Offline
          A Offline
          amonR
          wrote on last edited by
          #4

          Does it fix your problem when you use Qlabel like this:
          @
          QLabel *mypicture = new QLabel(this);
          mypicture->setPixmap(QPixmap(":/new/MyResources/launcher.png"));
          @

          1 Reply Last reply
          0
          • JeroentjehomeJ Offline
            JeroentjehomeJ Offline
            Jeroentjehome
            wrote on last edited by
            #5

            Hi,
            If for some reason it is the program startup you might want to consider a QSplashScreen instead? Maybe some extra options are available there. Otherwise you might need to have the widget you use to display the image (label?) set to transparent? Never tried a transparent before, so who knows

            Greetz, Jeroen

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fatih.aslantas
              wrote on last edited by
              #6

              [quote author="amonR" date="1386708307"]Does it fix your problem when you use Qlabel like this:
              @
              QLabel *mypicture = new QLabel(this);
              mypicture->setPixmap(QPixmap(":/new/MyResources/launcher.png"));
              @
              [/quote]

              when i use QLabel i get this http://prntscr.com/2a75x8 instead of black frame now it show gray frame

              1 Reply Last reply
              0
              • F Offline
                F Offline
                fatih.aslantas
                wrote on last edited by
                #7

                [quote author="Jeroentje@home" date="1386708413"]Hi,
                If for some reason it is the program startup you might want to consider a QSplashScreen instead? Maybe some extra options are available there. Otherwise you might need to have the widget you use to display the image (label?) set to transparent? Never tried a transparent before, so who knows[/quote]

                Thank you so much, QSplashScreen is solved my problem :) here is the result http://prntscr.com/2a78cf i get what i want :)
                here whole code that i wrote

                @#include "mainwindow.h"
                #include <QApplication>
                #include <QSplashScreen>

                int main(int argc, char *argv[])
                {
                QApplication a(argc, argv);

                QPixmap pixmap(":/new/MyResources/launcher.png");
                QSplashScreen splash(pixmap);
                    splash.show();
                
                a.processEvents();
                
                return a.exec&#40;&#41;;
                

                }@

                1 Reply Last reply
                0
                • JeroentjehomeJ Offline
                  JeroentjehomeJ Offline
                  Jeroentjehome
                  wrote on last edited by
                  #8

                  Hi,
                  The a.processEvents() is not needed here. The a.exec() does call it automatic. The QApplication when executed will handle the eventHandler.
                  But picture looks nice ;-)

                  Greetz, Jeroen

                  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