PDA

View Full Version : QGraphicsView Draw Foreground



augusbas
22nd June 2011, 11:22
Hi all,

I have designed a form of Main windows in designer and added QGraphicsview into it.

I have not sub-classed QGraphicsview in my class.......

I need to draw ellipse in the graphics-view foreground ..I have read from manuals,to do we need to override the drawforeground and subclass QGraphicsview ....

Without subclassing is there any possible way of doing it....drawing ellipse in the foreground of graphicsview ...

Advise me...

SixDegrees
22nd June 2011, 11:51
No. The base implementation of the function does nothing. You must subclass and provide a function with an implementation to draw whatever it is you want.

augusbas
22nd June 2011, 12:03
Hi,
Thanks for your suggestion

As i have mentioned i am using Designer and addded QGraphicsview from designer ...

My code on header beginning


class PPI_Wid : public QMainWindow , private Ui::PPIWindow
{
Q_OBJECT

public:

PPI_Wid(QWidget *parent = 0);


My CPP code beginning :



PPI_Wid::PPI_Wid(QWidget *parent) : QMainWindow(parent)
{
setupUi(this);



I tried changing my QmainWindow to QGraphicsview etc.....But SetupUi(this) gives me an Error .......

Now how do i sublass QGraphicsview and override the drawforeground .....Please provide some code snippets

Advise me...

SixDegrees
22nd June 2011, 12:26
In order to use Qt effectively, you need to learn C++ first. Inheritance is fundamental to C++. You can't just cobble together scraps of code you scrape off the Internet and expect them to work; you need to understand what you're doing and do the right thing.

Tools like Designer and Creator can help you build software projects, but they don't substitute for understanding. Learn the language first, then learn how to use the tools available for manipulating it.

augusbas
22nd June 2011, 13:01
In order to use Qt effectively, you need to learn C++ first. Inheritance is fundamental to C++..

Tools like Designer and Creator can help you build software projects, but they don't substitute for understanding. Learn the language first, then learn how to use the tools available for manipulating it.

You would have adviced me to try myself !!!!!! As simple as that

I didnt agree with your below quotes .....Code is mine ....I understood on what i am doing....

"You can't just cobble together scraps of code you scrape off the Internet and expect them to work; you need to understand what you're doing and do the right thing"

Anyhow thanks to your advice dude...