Results 1 to 6 of 6

Thread: QScrollArea - Painting happens in background , not in correct widget

  1. #1
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QScrollArea - Painting happens in background , not in correct widget

    Hi,

    i trying to Port a GUI from QT3 to QT4.

    The Scrolling in my Widget was implemented using QScrollview.

    The painting works correct, but the Pixmap is painted in the background (not the correct widget) in full size and there are no scrollbars.

    I think, that the setting of the widget is not happening correct..

    The painting is done on viewport()..

    Here's the piece of code I think the problem lies:
    Qt Code:
    1. xxx::xxx(..* , ..* ..) : QScrollArea(parent) {
    2. ...
    3.  
    4. QWidget* widget = new QWidget;
    5. QVBoxLayout* layout = new QVBoxLayout(this);
    6.  
    7. widget->setLayout(layout);
    8. setWidget(widget);
    9.  
    10. setBackgroundRole(QPalette::Dark);
    11.  
    12. ...
    13.  
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 


    Thx in advance
    --
    bensh

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QScrollArea - Painting happens in background , not in correct widget

    i suppose you are using the paintevent of your XXX::XXX class?

  3. #3
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QScrollArea - Painting happens in background , not in correct widget

    yep.. thats what I do..

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QScrollArea - Painting happens in background , not in correct widget

    Where and how are you painting the pixmap ?

  5. #5
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QScrollArea - Painting happens in background , not in correct widget

    Thanks for the fast reply..

    First in RefreshPixmap the pixmap is created (this works fine.. because it's painted correct, but in the wrong widget)

    Then I'm calling from PaintEvent a draw-function where the pixmap is painted onto the widget (viewport()).

    Somewhere below has to be the problem, but I already tried everything (


    Qt Code:
    1. void xxx::paintEvent(QPaintEvent* event) {
    2.  
    3.  
    4.  
    5. if (m_Pixmap.isNull()) refreshPixmap();
    6. draw(event->rect().x(), event->rect().y(), event->rect().width(), event->rect().height(),&p);
    7.  
    8.  
    9. }
    10.  
    11. void xxx::draw(int cx, int cy, int cw, int ch, QPainter* p) {
    12. p->begin(viewport());
    13. p->drawPixmap(0, 0, m_Pixmap);
    14.  
    15. p->drawPixmap(QRectF(cx - this->geometry().x(), cy- this->geometry().y(), cw, ch), m_Pixmap, QRectF(cx- this->geometry().x(), cy - this->geometry().y(), cw, ch));
    16. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Mar 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: QScrollArea - Painting happens in background , not in correct widget

    ................

Similar Threads

  1. QScrollArea misbehaving background style
    By Cruz in forum Qt Programming
    Replies: 6
    Last Post: 7th March 2021, 22:46
  2. Impossible to get correct widget background color
    By croscato in forum Qt Programming
    Replies: 4
    Last Post: 8th June 2009, 22:42
  3. background painting in the Scene
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 7th January 2008, 20:56
  4. Replies: 5
    Last Post: 4th November 2007, 12:35
  5. [qt4] QScrollArea corner widget?
    By sertrem in forum Qt Programming
    Replies: 2
    Last Post: 12th January 2006, 22:42

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.