Adding qpaint object to a Layout
I am rewriting a bit of code where there use to be a canvas and I am replacing it with a paint object. When I added the canvas to my gui all I had to do is tb->addWidget(canvas), where tb is a vertical layout. When I try to add the paint object to tb I get the error no matching function for call to ‘QHBoxLayout::addWidget(QPainter*&). I was wondering how would I add the paint object to tb where the canvas use to be.
When I say paint object, I mean QPaint paint. Not sure what the terminology is here. I am very new to QT.
Sorry if this is confusing to anybody.
Thanks
Re: Adding qpaint object to a Layout
Quote:
Originally Posted by
Rooster
I am rewriting a bit of code where there use to be a canvas and I am replacing it with a paint object. When I added the canvas to my gui all I had to do is tb->addWidget(canvas), where tb is a vertical layout. When I try to add the paint object to tb I get the error no matching function for call to ‘QHBoxLayout::addWidget(QPainter*&). I was wondering how would I add the paint object to tb where the canvas use to be.
When I say paint object, I mean QPaint paint. Not sure what the terminology is here. I am very new to QT.
Sorry if this is confusing to anybody.
Thanks
Here, You can use QGraphicsView object in place of QCanvas..
Re: Adding qpaint object to a Layout
Quote:
Originally Posted by
ashukla
That function was introduced in version 4.2 and I am using Qt 3.3, and can't upgrade because we have a commercial license for that version. Do you have any other suggestions?
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
Re: Adding qpaint object to a Layout
Quote:
Originally Posted by
marcel
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
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.
Re: Adding qpaint object to a Layout
Quote:
Originally Posted by
marcel
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?