Results 1 to 11 of 11

Thread: QMainWindow or QDialog show() - before displaying, the window area is painted white

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QMainWindow or QDialog show() - before displaying, the window area is painted whi

    Compare what I wrote:
    remove the style sheet from Dialog1.ui and modify the palette in Designer so that QPalette::Window is Red.
    to what you did in your code:
    Qt Code:
    1. QPalette pal = palette();
    2. pal.setColor(QPalette::Background, Qt::red);
    To copy to clipboard, switch view to plain text mode 

    You can actually make that palette adjustment to QPalette::Window in Designer if you wish. The QPalette::Window comes from the docs linked earlier.

    The other thing I did in your project was apply a layout to everything in your Dialog1. I do not think this will make a difference to the painting only the layout and usability.

  2. #2
    Join Date
    Oct 2020
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow or QDialog show() - before displaying, the window area is painted whi

    Quote Originally Posted by ChrisW67 View Post
    You can actually make that palette adjustment to QPalette::Window in Designer
    I changed the color of the palette-Window and others in the designer. But it didn't help

  3. #3
    Join Date
    Oct 2020
    Posts
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow or QDialog show() - before displaying, the window area is painted whi

    I solved this problem.

    Qt Code:
    1. class Dialog1 : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. explicit Dialog1(QWidget *parent = nullptr);
    7. ~Dialog1();
    8.  
    9. private:
    10. Ui::Dialog1 *ui;
    11. protected:
    12. bool event(QEvent*e);
    13. };
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. Dialog1::Dialog1(QWidget *parent) :
    2. QDialog(parent),ui(new Ui::Dialog1)
    3. {
    4. ui->setupUi(this);
    5.  
    6. setWindowFlags(Qt::Window);
    7. setWindowOpacity(0);
    8. }
    9.  
    10. bool Dialog1::event(QEvent*e)
    11. {
    12. if(e->type()==QEvent::WindowActivate)
    13. {
    14. QTimer::singleShot(0,NULL,[this](){this->setWindowOpacity(1);});
    15. return true;
    16. }
    17. if(e->type()==QEvent::Hide)
    18. {
    19. setWindowOpacity(0);
    20. return true;
    21. }
    22. return QDialog::event(e);
    23. }
    To copy to clipboard, switch view to plain text mode 
    This is not a Qt problem, this is a Windows problem. I looked at my WPF and Windows Forms projects and saw that they have this problem. You can also see it by running Windows Explorer or Windows Task Manager. Another question is whether this is considered a problem. I think so, Yes. This flickering hits my eyes
    Last edited by VVS; 27th October 2020 at 11:41.

  4. The following user says thank you to VVS for this useful post:

    d_stranz (27th October 2020)

Similar Threads

  1. Replies: 0
    Last Post: 13th October 2020, 13:42
  2. Replies: 2
    Last Post: 20th March 2015, 11:38
  3. 8bit greyscale raw picture find painted area
    By dazedly in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2012, 09:00
  4. Replies: 4
    Last Post: 15th July 2011, 18:31
  5. QDialog::show() not displaying child
    By Wasabi in forum Newbie
    Replies: 3
    Last Post: 14th September 2010, 01:38

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.