Results 1 to 12 of 12

Thread: Subclassing QGraphicsView

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QGraphicsView

    Using your previous tips I got compilation errors that says
    iadfuqgraphicsview.h:14: error: expected `,' or `...' before '*=' token
    iadfuqgraphicsview.cpp:4: error: prototype for `IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsS cene*, QWidget*)' does not match any in class `IADFUQGraphicsView'
    iadfuqgraphicsview.h:10: error: candidates are: IADFUQGraphicsView::IADFUQGraphicsView(const IADFUQGraphicsView&)
    iadfuqgraphicsview.h:14: error: IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsSc ene*, QWidget)

    iadfuqgraphicsview.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include "iadfuqgraphicsview.h"
    3. IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsScene *scene, QWidget* parent) :QGraphicsView(scene, parent)
    4. {
    5. }
    To copy to clipboard, switch view to plain text mode 

    complete header code
    Qt Code:
    1. #ifndef IADFUQGRAPHICSVIEW_H
    2. #define IADFUQGRAPHICSVIEW_H
    3.  
    4. class QObject;
    5. class QWidget;
    6.  
    7. class IADFUQGraphicsView : public QGraphicsView
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. IADFUQGraphicsView(QGraphicsScene*, QWidget*= NULL);
    13. ~IADFUQGraphicsView();
    14. };
    15.  
    16. #endif
    To copy to clipboard, switch view to plain text mode 
    Last edited by sincnarf; 27th August 2007 at 18:53. Reason: insufficient error report
    Image Analysis Development Framework Using Qt (IADFUQ)

  2. #2
    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: Subclassing QGraphicsView

    But I told you to include QGraphicsView in the header.

  3. #3
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QGraphicsView

    same error. sorry kind of sleepy here.

    I tried to place
    #include <QtGui/QGraphicsView>

    also tried to place
    #include <QGraphicsView>

    also tried the forward declaration
    class QGraphicsView;

    still got the same error as before
    iadfuqgraphicsview.h:16: error: expected `,' or `...' before '*=' token
    iadfuqgraphicsview.cpp:4: error: prototype for `IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsS cene*, QWidget*)' does not match any in class `IADFUQGraphicsView'
    iadfuqgraphicsview.h:12: error: candidates are: IADFUQGraphicsView::IADFUQGraphicsView(const IADFUQGraphicsView&)
    iadfuqgraphicsview.h:16: error: IADFUQGraphicsView::IADFUQGraphicsView(QGraphicsSc ene*, QWidget)
    Image Analysis Development Framework Using Qt (IADFUQ)

  4. #4
    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: Subclassing QGraphicsView

    Try this:

    the header(customgv.h):
    Qt Code:
    1. #ifndef CUSTOMGV_H
    2. #define CUSTOMGV_H
    3.  
    4. #include <QGraphicsView>
    5.  
    6. class QWidget;
    7.  
    8. class customgv : public QGraphicsView
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13. customgv(QGraphicsScene*, QWidget*= NULL);
    14. ~customgv();
    15. };
    16. #endif
    To copy to clipboard, switch view to plain text mode 

    the cpp(customgv.cpp):
    Qt Code:
    1. #include <QtGui>
    2. #include "customgv.h"
    3. customgv::customgv(QGraphicsScene *scene, QWidget* parent) :QGraphicsView(scene, parent)
    4. {
    5. }
    To copy to clipboard, switch view to plain text mode 

    You might have another class named IADF...

    Regards

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

    sincnarf (27th August 2007)

  6. #5
    Join Date
    Apr 2007
    Posts
    117
    Thanks
    84
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QGraphicsView

    What the.. this worked. Now trying to override contextMenuEvent and mousePressEvent s
    Image Analysis Development Framework Using Qt (IADFUQ)

Similar Threads

  1. QGraphicsView
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2007, 08:00
  2. Speed, transparency, and drop issues with QGraphicsView
    By jefferai in forum Qt Programming
    Replies: 16
    Last Post: 30th June 2007, 16:14
  3. no image displayed on QGraphicsView
    By sincnarf in forum Qt Programming
    Replies: 9
    Last Post: 28th June 2007, 12:33
  4. QGraphicsView and item focus
    By Micawber in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2007, 20:36
  5. Using QGraphicsView with model/view programming
    By JLP in forum Qt Programming
    Replies: 3
    Last Post: 29th January 2007, 11:04

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.