Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6569179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:35:39+00:00 2026-05-25T14:35:39+00:00

Now I want to change the ui->widget->windowOpacity and ui->stackedWidget->windowOpacity() ,but failed. void Widget::on_pushButton_clicked() {

  • 0

Now I want to change the ui->widget->windowOpacity and ui->stackedWidget->windowOpacity() ,but failed.

void Widget::on_pushButton_clicked()
{
   QTimer *timerOpacity = new QTimer(this);
   connect(timerOpacity,SIGNAL(timeout()),this,SLOT(changeOpacity()));
   timerOpacity->start(100);
}

void Widget::changeOpacity()
{
    if (opalevel > 8) return;

    double opacity[9] =  {0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1};

    ui->stackedWidget->setWindowOpacity(opacity[opalevel]);
    ui->widget->setWindowOpacity(opacity[opalevel]);
    this->setWindowOpacity(opacity[opalevel]);

    qDebug()<<"opalevel = "<< opalevel <<" ui->widget opacity:"<<ui->widget->windowOpacity();
    qDebug()<<"opalevel = "<< opalevel <<" ui->stackedWidget opacity:"<<ui->stackedWidget->windowOpacity();
    qDebug()<<"opalevel = "<< opalevel <<" ui opacity : "<< this->windowOpacity()<<endl;

    opalevel++;
}  

Debug log :

opalevel =  0  ui->widget opacity: 1 
opalevel =  0  ui->stackedWidget opacity: 1 
opalevel =  0  ui opacity:  0.898039 

opalevel =  1  ui->widget opacity: 1 
opalevel =  1  ui->stackedWidget opacity: 1 
opalevel =  1  ui opacity:  0.8 

opalevel =  2  ui->widget opacity: 1 
opalevel =  2  ui->stackedWidget opacity: 1 
opalevel =  2  ui opacity:  0.698039 

opalevel =  3  ui->widget opacity: 1 
opalevel =  3  ui->stackedWidget opacity: 1 
opalevel =  3  ui opacity:  0.596078 

opalevel =  4  ui->widget opacity: 1 
opalevel =  4  ui->stackedWidget opacity: 1 
opalevel =  4  ui opacity:  0.498039 

opalevel =  5  ui->widget opacity: 1 
opalevel =  5  ui->stackedWidget opacity: 1 
opalevel =  5  ui opacity:  0.4 

opalevel =  6  ui->widget opacity: 1 
opalevel =  6  ui->stackedWidget opacity: 1 
opalevel =  6  ui opacity:  0.298039 

opalevel =  7  ui->widget opacity: 1 
opalevel =  7  ui->stackedWidget opacity: 1 
opalevel =  7  ui opacity:  0.2 

opalevel =  8  ui->widget opacity: 1 
opalevel =  8  ui->stackedWidget opacity: 1 
opalevel =  8  ui opacity:  0.0980392 

Thank you for your help .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:35:40+00:00Added an answer on May 25, 2026 at 2:35 pm

    You can use QGraphicsOpacityEffect on your non-top-level widgets:

    // in the constructor
    opacityEffect = new QGraphicsOpacityEffect;
    ui->widget->setGraphicsEffect(opacityEffect);
    ...
    // in changeOpacity()
    opacityEffect->setOpacity(opacity[opalevel]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am an old time Visual SourceSafe developer but now I want to change
<RelativeLayout android:id=@+id/widget android:layout_width=match_parent android:layout_height=wrap_content android:background=@drawable/my_background android:orientation=vertical > And now I want to change this
I use several referenced tables with integer primary keys. Now I want to change
It's now 925*1139,I want to change it to 90*110.
Following on from this question , I now want to know how to stop
i have wrote a script to produce an array of data but now want
I'm embarking on a new web app we want do do it RESTfully. Now
I've forked a Mercurial repository, and now I want to pull the changes from
I have till now mainly concentrated on web programming thus far and now want
I deleted a file from a repo and now want to put it back.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.