Results 1 to 7 of 7

Thread: Adding qpaint object to a Layout

Hybrid View

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

    Default Re: Adding qpaint object to a Layout

    You mean a QPainter?
    You can't add a QPainter to anything. QPainter is used just to paint on paint devices.
    If you want to create a graphical object to substitute the canvas, you can create a QWidget subclass and paint on it.

    Regards

  2. #2
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Adding qpaint object to a Layout

    Quote Originally Posted by marcel View Post
    You mean a QPainter?
    You can't add a QPainter to anything. QPainter is used just to paint on paint devices.
    If you want to create a graphical object to substitute the canvas, you can create a QWidget subclass and paint on it.
    Yes, I mean QPainter. Sorry about that. Is creating a QWidget subclass the best way to go? What I am doing is I have three checkboxes that correspond to three different graphs. If two of the boxes are checked then two of the graphs are drawn. If all three boxes are checked then all three graphs are drawn. I decided to use QPainter instead of canvas because of issues with the scaling and drawing the lines in canvas was getting problematic. Could there be a better way of doing this than using QPainter?


    Thanks

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

    Default Re: Adding qpaint object to a Layout

    But you don't understand.
    You must use QPainter *AND* QWidget. You use the painter to draw on the widget. That is the only way. What would you do with a QPainter alone?

    And subclassing QWidget shouldn't be a problem.

  4. #4
    Join Date
    Feb 2008
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Adding qpaint object to a Layout

    Quote Originally Posted by marcel View Post
    But you don't understand.
    You must use QPainter *AND* QWidget. You use the painter to draw on the widget. That is the only way. What would you do with a QPainter alone?

    And subclassing QWidget shouldn't be a problem.
    I think I get it now. Create a QWidget that will do all of the QPainter things to it. Then build the other widget around it. Is this correct?

Similar Threads

  1. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  2. Adding numbers to circles in QPaint
    By therealjag in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2006, 10: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
  •  
Qt is a trademark of The Qt Company.