Results 1 to 5 of 5

Thread: QScrollArea and Painting issue

  1. #1
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default QScrollArea and Painting issue

    I've built my own QScrollArea-based widget, it will have or not have a scrollbar.
    If it has a scrollbar, a content widget will be added and painting would be happened on content widget.
    If it doesn't have a scrollbar, it would work as a simple frame widget.

    However, I found that when there was no scrollbar, I can't paint anything on it in overridden paintEvent(). The paint event was received and some paintings was done, but no effect.

    I'm wondering it's that QSrcollArea disabled painting by default.
    I'm looking for someone could help me confirm it.
    Thx.

  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: QScrollArea and Painting issue

    Please provide a minimal compilable example reproducing the problem.
    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
    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 and Painting issue

    also play around with viewport() and viewportwidget, and have your paintevent on the relevant widget

  4. #4
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QScrollArea and Painting issue

    Quote Originally Posted by wysota View Post
    Please provide a minimal compilable example reproducing the problem.
    Pls check out attachment. I quickly built a demo, but weird, both paintEvent never got called.

    QScrollAreaWidget.zip

    Quote Originally Posted by MrDeath View Post
    also play around with viewport() and viewportwidget, and have your paintevent on the relevant widget
    I just learned about viewport() which said QScrollArea will assign a new QWidget anyway for viewport if I missed set one, I'm afraid that if it's quite appropriate for my initial purpose of making it being a normal frame widget if there's no scrollbar.

  5. #5
    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 and Painting issue

    consider using a stackwidget for displaying your two views. set one to QFrame and another to QScrollArea

Similar Threads

  1. Replies: 5
    Last Post: 19th March 2010, 18:13
  2. Regarding Painting
    By archanasubodh in forum General Programming
    Replies: 6
    Last Post: 8th August 2008, 18:23
  3. Replies: 2
    Last Post: 10th March 2008, 20:16
  4. QListWidget painting issue
    By guilugi in forum Qt Programming
    Replies: 6
    Last Post: 16th April 2007, 17:06
  5. About painting
    By Pang in forum Qt Programming
    Replies: 3
    Last Post: 28th March 2007, 17:21

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.