Results 1 to 12 of 12

Thread: [qt5] repainting qwidget

  1. #1
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default [qt5] repainting qwidget

    Hello.

    Qt Code:
    1. void dUpload::show( Qt::WindowFlags flags )
    2. {
    3. //setWindowFlags( flags );
    4.  
    5. setAttribute(Qt::WA_NoSystemBackground, true);
    6.  
    7. show();
    8. }
    To copy to clipboard, switch view to plain text mode 

    After call setAttribute function from this code my qwidget doesn't repaint (i.e. I see artefacts from child widgets), but when I resize that widget, then it repaints.

    Is it bug in qt5 or I do something wrong?

    OS: win7 + msvs 2010.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    What does your paint event look like?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default Re: [qt5] repainting qwidget

    Firstly (when I created this topic) I didn't use paintEvent.
    Now it is:
    Qt Code:
    1. void dUpload::paintEvent( QPaintEvent *event )
    2. {
    3. QPainter p(this);
    4. p.setCompositionMode(QPainter::CompositionMode_Clear);
    5. p.fillRect(0, 0, width(), height(), Qt::BrushStyle::SolidPattern);
    6. }
    To copy to clipboard, switch view to plain text mode 
    and this resolved my problem (artefacts goes away). But I think it's just hack

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    So why are you using the NoSystemBackground attribute?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default Re: [qt5] repainting qwidget

    Quote Originally Posted by wysota View Post
    So why are you using the NoSystemBackground attribute?
    I need to make my widget glass-styled (windows 7), and for that I use this code:
    Qt Code:
    1. void dUpload::show( Qt::WindowFlags flags )
    2. {
    3. setWindowFlags( flags );
    4.  
    5. //setAttribute(Qt::WA_NoSystemBackground, true); // 1
    6. setAttribute(Qt::WA_TranslucentBackground, true); // 2
    7.  
    8. if ( QtWin::isCompositionEnabled() )
    9. QtWin::extendFrameIntoClientArea( this );
    10.  
    11. show();
    12. }
    To copy to clipboard, switch view to plain text mode 
    1 and 2 are equal, i.e. widget will be glassed, but not repainted.

    UPD: screenshot when it doesn't repaint:
    Last edited by zodiac; 24th July 2012 at 17:21.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    They are definitely not equal. (1) is wrong, (2) is correct.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default Re: [qt5] repainting qwidget

    Quote Originally Posted by wysota View Post
    They are definitely not equal. (1) is wrong, (2) is correct.
    But widget also doesn't automatically repaint when (2) is activated.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    It does repaint. It just doesn't paint its background.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default Re: [qt5] repainting qwidget

    Quote Originally Posted by wysota View Post
    It does repaint. It just doesn't paint its background.
    Do you mean this is normal behaviour? But in qt4 I didn't see any artefacts.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    Qt5 is still pre-beta, so I would expect glitches.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jul 2012
    Posts
    7
    Platforms
    Windows

    Default Re: [qt5] repainting qwidget

    Quote Originally Posted by wysota View Post
    Qt5 is still pre-beta, so I would expect glitches.
    Ok, I thought such bugs can't be in beta.
    Last edited by zodiac; 25th July 2012 at 14:39.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: [qt5] repainting qwidget

    It's not beta, it's pre-beta. Besides I don't know if what you experience is a glitch or not. I'm just saying glitches are expected.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Repainting a QGraphicsView
    By Luc4 in forum Qt Programming
    Replies: 8
    Last Post: 29th April 2010, 14:09
  2. QGraphicsItem not repainting
    By eijnuhs in forum Qt Programming
    Replies: 3
    Last Post: 20th September 2008, 08:54
  3. Replies: 4
    Last Post: 8th August 2008, 17:28
  4. repainting through paintEvent() function
    By salmanmanekia in forum Qt Programming
    Replies: 5
    Last Post: 6th August 2008, 12:50
  5. Repainting widget
    By fear in forum Qt Programming
    Replies: 3
    Last Post: 26th March 2008, 08:37

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.