I have made an empty widget that is of my application size placing on my application as a child and in that empty widget I have placed my dialog widget(now my dialog widget is win) in the center and made the widget transparent so that I can block events to background application.

Qt Code:
  1. dilog->resize(QApplication::activeWindow()->width(), QApplication::activeWindow()->height());
To copy to clipboard, switch view to plain text mode 

Now I tried to paint my background application with black color. Initially it was fine but when application is resized then it is not painting the latest resized part of my application although my empty widget is being increased with my application size.
Qt Code:
  1. void dialog:: paintEvent(QPaintEvent* event)
  2. {
  3. QPainter painter(this);
  4. QRect rect(0, 0, this->parentWidget()->width(), this->parentWidget()->height());
  5. painter.drawRect(rect);
  6. QColor color(Qt::black);
  7. color.setAlpha(100);
  8. painter.fillRect(rect, color);
  9. }
  10.  
  11.  
  12. bool dialog::eventFilter(QObject* obj, QEvent* event)
  13. {
  14.  
  15. if (event->type() == QEvent::Resize)
  16. {
  17. QResizeEvent *resize= static_cast<QResizeEvent*> (event);
  18. this->resize(resize->size());
  19. win->move(dialog->width()/2-win->width()/2, dialog->height()/2-win->height()/2);
  20. this->repaint();
  21. }
  22. if (event->type() == QEvent::Paint)
  23.  
  24. return false;
  25.  
  26. return true;
  27. }
To copy to clipboard, switch view to plain text mode 
May be this is due to my paintevent hasn't able to fetch the latest application size . How can I get my application size for every resize event so that I can paint the background