Results 1 to 7 of 7

Thread: Inheritance problem

  1. #1
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Inheritance problem

    Hi guys!

    I'm trying to use QComboBox as my base class for my ComboView, but I'm having a problem when I try build my program:

    hudson@brevleq:~/.projetos/CLP$ make
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/qt4/mkspecs/linux-g++ -I. -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtCore -I/opt/qt4/include/QtGui -I/opt/qt4/include/QtGui -I/opt/qt4/include -I. -Icontainer -Iporta -Iobserver -Iobserver/events -Igenerator -Icontroller -Iview -Ifrontend -I. -I. -o ComboView.o view/ComboView.cpp
    view/ComboView.cpp: In constructor 'ComboView::ComboView(QWidget*)':
    view/ComboView.cpp:14: error: no matching function for call to 'ComboView::currentIndexChanged()'
    /opt/qt4/include/QtGui/qcombobox.h:230: note: candidates are: void QComboBox::currentIndexChanged(int)
    /opt/qt4/include/QtGui/qcombobox.h:231: note: void QComboBox::currentIndexChanged(const QString&)
    view/ComboView.cpp:14: error: 'signal' was not declared in this scope
    view/ComboView.cpp:14: error: 'slot' was not declared in this scope
    make: ** [ComboView.o] Erro 1
    hudson@brevleq:~/.projetos/CLP$
    I think the inheritance I did is wrong, but I can't find the problem!!
    These are the sources:

    Qt Code:
    1. #ifndef COMBOVIEW_H
    2. #define COMBOVIEW_H
    3.  
    4. #include <QComboBox>
    5. #include <QWidget>
    6. #include "View.h"
    7. #include "PortaEntrada.h"
    8.  
    9. class ComboView : public QComboBox,public View {
    10. Q_OBJECT
    11.  
    12. public:
    13. ComboView(QWidget *parent=0);
    14.  
    15. protected slots:
    16. void typeChanged(void);
    17. };
    18.  
    19. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "ComboView.h"
    2.  
    3. ComboView::ComboView(QWidget *parent):QComboBox(parent){
    4. addItem("Constante",PortaEntrada::CONSTANT);
    5. addItem("Triangular",PortaEntrada::TRIANGULAR);
    6. addItem("Quadratica",PortaEntrada::QUADRATIC);
    7. QComboBox::connect(this,signal(currentIndexChanged()),this,slot(typeChanged()));
    8. }
    9.  
    10. void ComboView::typeChanged(void){
    11. controller->setProperty(currentIndex());
    12. }
    To copy to clipboard, switch view to plain text mode 

    what I did wrong?

  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: Inheritance problem

    It should be "SIGNAL(currentIndexChanged())" and "SLOT(typeChanged())". Notice upper case.
    J-P Nurmi

  3. #3
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inheritance problem

    Good!

    I've forgot it!
    It's building right now, but when I run the program I have this output at shell:

    hudson@brevleq:~/.projetos/CLP$ CLP
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    Object::connect: No such signal ComboView::QComboBox::currentIndexChanged()
    hudson@brevleq:~/.projetos/CLP$
    I wanna use QComboBox Signal, can I?? How?? Should I reimplement currentIndexChanged()??

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Inheritance problem

    Please post your updated connect() statement. It probably contains SIGNAL(QComboBox::currentIndexChanged()) instead of SIGNAL(currentIndexChanged()).

  5. #5
    Join Date
    Aug 2007
    Posts
    64
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inheritance problem

    Qt Code:
    1. #include "ComboView.h"
    2.  
    3. ComboView::ComboView(QWidget *parent):QComboBox(parent){
    4. addItem("Constante",PortaEntrada::CONSTANT);
    5. addItem("Triangular",PortaEntrada::TRIANGULAR);
    6. addItem("Quadratica",PortaEntrada::QUADRATIC);
    7. connect(this,SIGNAL(currentIndexChanged(&int)),this,SLOT(typeChanged()));
    8. }
    9.  
    10. void ComboView::typeChanged(void){
    11. controller->setProperty(currentIndex());
    12. }
    To copy to clipboard, switch view to plain text mode 


    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)
    Object::connect: No such signal ComboView::currentIndexChanged(&int)

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inheritance problem

    connect(this,SIGNAL(currentIndexChanged(&int)),thi s,SLOT(typeChanged()));

    should be

    connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(typeChanged()));

  7. #7
    Join Date
    Dec 2008
    Location
    chinese
    Posts
    47
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Inheritance problem

    Quote Originally Posted by brevleq View Post
    Qt Code:
    1. #include "ComboView.h"
    2.  
    3. ComboView::ComboView(QWidget *parent):QComboBox(parent){
    4. addItem("Constante",PortaEntrada::CONSTANT);
    5. addItem("Triangular",PortaEntrada::TRIANGULAR);
    6. addItem("Quadratica",PortaEntrada::QUADRATIC);
    7. connect(this,SIGNAL(currentIndexChanged(&int)),this,SLOT(typeChanged()));
    8. }
    9.  
    10. void ComboView::typeChanged(void){
    11. controller->setProperty(currentIndex());
    12. }
    To copy to clipboard, switch view to plain text mode 
    parent class have no currentIndexChanged signal, i think

Similar Threads

  1. problem in widget inheritance
    By wagmare in forum Qt Programming
    Replies: 2
    Last Post: 10th December 2008, 07:35
  2. Possibly an inheritance problem with QObject?
    By chadkeck in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2008, 01:26
  3. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  4. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  5. How much inheritance do you use?
    By Michiel in forum General Programming
    Replies: 8
    Last Post: 1st August 2006, 22:29

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.