Results 1 to 4 of 4

Thread: How to make a mainwindow as earlier after making it transparent

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default How to make a mainwindow as earlier after making it transparent

    Hi all

    I want to make my background transparent when clicked a button and after clicking on another button i want to make background as it was earlier. I try

    Qt Code:
    1. this->setStyleSheet("background:transparent");
    2. this->setAttribute(Qt::WA_TranslucentBackground, true);
    3. this->setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. this->setStyleSheet("background:transparent");
    2. this->setAttribute(Qt::WA_TranslucentBackground, false);
    3. this->setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    but not getting desired result.
    What i am doing here.
    Waiting for yours response.
    Last edited by Niamita; 9th January 2012 at 07:29.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to make a mainwindow as earlier after making it transparent

    Try to set an empty style sheet or simply use QPalette and set the default background or save the properties before you set the transparent background.

  3. #3
    Join Date
    May 2011
    Posts
    120
    Thanks
    9
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: How to make a mainwindow as earlier after making it transparent

    Thanks for reply.
    Can you give some example code.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to make a mainwindow as earlier after making it transparent

    Qt Code:
    1. void MainWindow::on_a_clicked()
    2. {
    3. setAttribute(Qt::WA_TranslucentBackground, true);
    4. setStyleSheet("background:transparent;");
    5. }
    6.  
    7. void MainWindow::on_b_clicked()
    8. {
    9. setAttribute(Qt::WA_TranslucentBackground, false);
    10. setStyleSheet("background:red;");
    11. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 3
    Last Post: 18th July 2019, 10:25
  2. How to make overlapping widgets opaque ?
    By ada10 in forum Newbie
    Replies: 3
    Last Post: 9th September 2010, 10:06
  3. Replies: 0
    Last Post: 25th August 2010, 17:39
  4. Replies: 2
    Last Post: 19th August 2008, 09:46
  5. Making some part of window transparent
    By yogeshm02 in forum Qt Programming
    Replies: 1
    Last Post: 27th March 2006, 20:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.