Results 1 to 5 of 5

Thread: QGraphicsView Draw Foreground

  1. #1
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QGraphicsView Draw Foreground

    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...

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView Draw Foreground

    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.

  3. #3
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView Draw Foreground

    Hi,
    Thanks for your suggestion

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

    My code on header beginning

    Qt Code:
    1. class PPI_Wid : public QMainWindow , private Ui::PPIWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6.  
    7. PPI_Wid(QWidget *parent = 0);
    To copy to clipboard, switch view to plain text mode 

    My CPP code beginning :

    Qt Code:
    1. PPI_Wid::PPI_Wid(QWidget *parent) : QMainWindow(parent)
    2. {
    3. setupUi(this);
    To copy to clipboard, switch view to plain text mode 

    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...

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsView Draw Foreground

    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.

  5. The following user says thank you to SixDegrees for this useful post:

    augusbas (22nd June 2011)

  6. #5
    Join Date
    Jun 2009
    Location
    India
    Posts
    143
    Thanks
    16
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView Draw Foreground

    Quote Originally Posted by SixDegrees View Post
    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...

Similar Threads

  1. Replies: 1
    Last Post: 9th April 2009, 14:54
  2. how to draw lines on image using QGraphicsView in Qt4
    By madhavilatha in forum What's New in Qt 4.4
    Replies: 1
    Last Post: 25th July 2008, 00:32
  3. Setting QGraphicsView bacground/foreground color
    By zolookas in forum Qt Tools
    Replies: 1
    Last Post: 28th June 2008, 16:55
  4. How to keep window in foreground
    By szicsi in forum Qt Programming
    Replies: 5
    Last Post: 17th January 2008, 14:40
  5. Updating Foreground for QGraphicsView
    By tts80 in forum Qt Programming
    Replies: 5
    Last Post: 4th January 2007, 15:28

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.