Results 1 to 6 of 6

Thread: problem painting

  1. #1
    Join Date
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default problem painting

    within an MDI I have subwindows as QScrollArea with a QWidget scrollAreaWidgetContents inside


    Qt Code:
    1. childScrollArea::childScrollArea(QWidget *parent) :
    2. QScrollArea(parent),
    3. m_ui(new Ui::childScrollArea)
    4. {
    5.  
    6. scrollAreaWidgetContents = new QWidget();
    7. childScrollArea->setWidget(scrollAreaWidgetContents);
    8.  
    9. scrollAreaWidgetContents->show();
    10.  
    11. }
    12.  
    13.  
    14. void childScrollArea::paintEvent(QPaintEvent * /* event */)
    15. {
    16. QPainter painter(this);
    17.  
    18. painter.fillRect(QRect(0, 0, 300, 300), Qt::blue );
    19. }
    To copy to clipboard, switch view to plain text mode 


    unfortunately the paint event in this case does not do any painting in the window!

    what do i do wrong?

    Thanks for any hint
    Last edited by wysota; 12th August 2009 at 19:58. Reason: missing [code] tags

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

    Default Re: problem painting

    QScrollArea has a viewport, you should probably be painting on that, if at all.
    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
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default Re: problem painting

    ok the viewport did the display part, but i cannot get the scroll bar to show, whatever the size of my widget inside... so what else is missing?

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

    Default Re: problem painting

    It depends what the widget does. Does it have a layout?
    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
    Aug 2009
    Posts
    81
    Platforms
    MacOS X Windows

    Default Re: problem painting

    i tried with a layout around the widget.. i don't get it to work..

    also what is strange is that i do not have any event like mouse event within the minimum size of my scroll area, outside the minimum size i do have mouse event. i am sure it is related and i am missing something, i have no clue what

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

    Default Re: problem painting

    If it doesn't have a layout then its size is probably not constrained in any way. How do you set the size of this widget?
    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. Painting problem
    By ScoOteR in forum Qt Programming
    Replies: 5
    Last Post: 11th March 2007, 11:03
  2. Painting Problem on Mac
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2007, 08:58
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.