Results 1 to 2 of 2

Thread: Can't compile custom QValidator

  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Thanks
    29
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Can't compile custom QValidator

    Can anyone see why this doesn't compile ?

    header file:
    Qt Code:
    1. #include <QValidator>
    2. class QvDateValidator : public QValidator
    3. {
    4. public:
    5. QvDateValidator(QObject * parent);
    6. protected:
    7. void fixup ( QString & input ) const;
    8. QValidator::State validate ( QString & input, int & pos ) const;
    9. };
    To copy to clipboard, switch view to plain text mode 

    source file:
    Qt Code:
    1. #include "qvdatevalidator.h"
    2.  
    3. QvDateValidator::QvDateValidator(QObject * parent)
    4. {
    5. }
    To copy to clipboard, switch view to plain text mode 

    qvdatevalidator.cpp: In constructor ‘QvDateValidator::QvDateValidator(QObject*)à ¢â‚¬â„¢:
    qvdatevalidator.cpp:4: error: no matching function for call to ‘QValidator::QValidator()’
    /usr/include/qt4/QtGui/qvalidator.h:92: note: candidates are: QValidator::QValidator(const QValidator&)
    /usr/include/qt4/QtGui/qvalidator.h:89: note: QValidator::QValidator(QValidatorPrivate&, QObject*)
    /usr/include/qt4/QtGui/qvalidator.h:88: note: QValidator::QValidator(QObjectPrivate&, QObject*)
    /usr/include/qt4/QtGui/qvalidator.h:64: note: QValidator::QValidator(QObject*)
    qvdatevalidator.cpp: At global scope:
    Last edited by vieraci; 22nd August 2009 at 14:33. Reason: spelling error

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Can't compile custom QValidator

    because (as the compiler tried to tell you) QValidator does not have a default constructor (one without args). You need to pass parent to it:

    Qt Code:
    1. QvDateValidator::QvDateValidator(QObject * parent)
    2. : QValidator(parent)
    3. {}
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to caduel for this useful post:

    vieraci (23rd August 2009)

Similar Threads

  1. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 07:18
  2. Replies: 2
    Last Post: 16th May 2008, 14:39
  3. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 09:02
  4. Compile Errors (porting Custom widget from Qt3 to Qt4)
    By degs2k4 in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2008, 22:18
  5. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38

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.