Results 1 to 11 of 11

Thread: Painting problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Painting problem

    Marcel,

    Thanks for your patience.

    I get no errors when running the last piece of code I sent; it just doesn't paint. I printed out this->width() and this->height just before the call to eraseRect, and it shows the size of pbs to be (2, 109, 644, 15). I removed the line that was clearly out of the print area, compiled, and ran it again. Still no painting.

    WRT the size of the widgets, I would think that's set in updateLayout(). I didn't write the original code, so I'm not sure why the author chose to implement it that way.

    I'll have many changes in arithmetic to make in the program, but I feel that if I can get the toy I posted to run I'll be able to conquer the rest.

    Thanks.

    Cheers,
    Mel

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Painting problem

    Instead of drawing the lines try p.fillRect( rect(), Qt::red ) ;
    See if anything is being painted now. Perhaps you need to set a width for the pen.

    regards

  3. #3
    Join Date
    May 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Painting problem

    Marcel,

    p.fillRect( rect(), Qt::red ) ;

    filled pbs with a bright red.

    The pen width is set to 0, so a 1 pixel width line should be drawn.

    I removed the background from pbs, but still no line.

    Thus far the only thing I've been able to display on pbs is your fillRect suggestion.
    I also tried
    p.fillRect(4,115,34,6,Qt::red);
    which should have filled a small rectangle, but nothing happened.

    It's probably late in your area, but do you have any last suggestions for today?

    Thanks again.

    Cheers,
    Mel

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Painting problem

    OK.
    A painter draws in paint device (widget in this case ) local coordinates.
    Meaning that when you used my previous suggestion, something got filled, but not the right thing .

    Thus, everything must be drawn relative to (0,0).
    Calling p.fillRect( 0, 0, size().width(), size().height(), Qt:red ) will fill the ENTIRE widget.
    For what you were trying to achieve call p.fillRect( 0, 0, 30, 6, Qt:red ). This will fill a small rect in the top left corner of the widget.

    To be sure just do a drawRect( 0, 0, size().width(), size().height() ) - draw a frame around the widget.

    If this works ( and it will ), draw everything relative to (0, 0 ) - lines, etc.

    It's probably late in your area, but do you have any last suggestions for today?
    It's 11 PM, not so late.

    Regards

  5. #5
    Join Date
    May 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Painting problem

    Sigh ... Of course it's relative! I knew there was some fundamental point I was missing! I adjusted my numbers, and painted the rectangle and the line I was trying to paint.

    I can't thank you enough for your help, Marcel. I have a lot of work still ahead, but your help has removed a big roadblock. I put my question out to this group, because they had advertised a 95% success rate in solving users' problems. Mine can certainly be added to the success list thanks to your efforts.

    Thanks again for your time and patience.

    Cheers,
    Mel

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Painting problem

    Happy to be of some help!

    Regards

Similar Threads

  1. Painting problem
    By ScoOteR in forum Qt Programming
    Replies: 5
    Last Post: 11th March 2007, 12:03
  2. Painting Problem
    By shyam prasad in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2007, 15:07
  3. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 15:08
  5. Replies: 16
    Last Post: 7th March 2006, 16: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.