Results 1 to 5 of 5

Thread: What's wrong with my GMCButton?

  1. #1
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default What's wrong with my GMCButton?

    Hi,
    I have almost completed my application and now I am working on restyling the gui. I started creating a new GMCButton like this:
    Qt Code:
    1. class GMCButton: public QPushButton
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. GMCButton(QWidget *parent = 0);
    7. };
    To copy to clipboard, switch view to plain text mode 

    then in my centralwidget.cpp

    searchButton = new GMCButton(tr("&Open search dialog"));

    During compilation I got this error:

    [HTML]mainwindow.cpp: In constructor ‘MainWindow::MainWindow()’:
    mainwindow.cpp:41: error: no matching function for call to ‘MainWindow::connect(GMCButton*&, const char [11], MainWindow* const, const char [20])’
    /usr/include/qt4/QtCore/qobject.h:191: note: candidates are: static bool QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
    /usr/include/qt4/QtCore/qobject.h:292: note: bool QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const[/HTML]

    in correspondence of this line (in mainwindow.cpp):

    Qt Code:
    1. connect(centralWidget->searchButton, SIGNAL(clicked()), this, SLOT(viewSearchDialog()));
    To copy to clipboard, switch view to plain text mode 

    Why this error?

    Regards
    Giuseppe CalÃ

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: What's wrong with my GMCButton?

    Try including "gmcbutton.h" in "mainwindow.cpp".
    J-P Nurmi

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

    jiveaxe (8th November 2007)

  4. #3
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: What's wrong with my GMCButton?

    Oops, what stupid error...

    Thanks
    Giuseppe CalÃ

  5. #4
    Join Date
    Aug 2007
    Posts
    244
    Thanks
    42
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: What's wrong with my GMCButton?

    Now I am afraid to post a new potentially stupid question, but I do it:

    After correcting the code as jpn said, now at the and of compilation I got this error:

    gmcwidgets.cpp:5: undefined reference to `vtable for GMCButton'

    The incriminated code is:

    Qt Code:
    1. GMCButton::GMCButton(QWidget *parent, QString text)
    2. :QPushButton(parent)
    3. {
    4. setFixedHeight(28);
    5. setText(text);
    6. }
    To copy to clipboard, switch view to plain text mode 

    line 5 is :QPushButton(parent)

    The updated GMCButton class is:

    Qt Code:
    1. class GMCButton: public QPushButton
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. GMCButton(QWidget *parent = 0, QString text = "");
    7. };
    To copy to clipboard, switch view to plain text mode 

    Thanks

    EDIT: The problem is gone alone.
    Last edited by jiveaxe; 8th November 2007 at 10:53.
    Giuseppe CalÃ

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: What's wrong with my GMCButton?

    Quote Originally Posted by jiveaxe View Post
    Now I am afraid to post a new potentially stupid question, but I do it:
    ...
    gmcwidgets.cpp:5: undefined reference to `vtable for GMCButton'
    Heh, there is no need to be afraid but search the forums always before asking, please. This is one of the most common errors while compiling Qt applications. This has been asked and answered tons of times on the forums. Just try searching for "vtable"..
    J-P Nurmi

Similar Threads

  1. Replies: 7
    Last Post: 17th July 2009, 09:40
  2. border color is wrong with "plastique" style in Qt4.2.3
    By alfa_wu in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2007, 04:27
  3. [delegate] wrong commit for boolean
    By lauranger in forum Qt Programming
    Replies: 3
    Last Post: 26th October 2006, 08:14
  4. QListWidget...what's wrong
    By nupul in forum Newbie
    Replies: 16
    Last Post: 4th April 2006, 12:17
  5. Help please - what am I doing wrong?
    By Jimmy2775 in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2006, 22:06

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.