Results 1 to 5 of 5

Thread: "no matching function for call to 'UserCreationDialog::Connect(..."

  1. #1
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default "no matching function for call to 'UserCreationDialog::Connect(..."

    Hi,

    I have two classes, UserConfiguration and UserCreationDialog, in my C++ Qt Project. I need to make a connection between a signal from UserCreationDialog, when OK button is pressed and the slot update() in UserConfiguration. The connection is seen in my code below. But when I build, I get the error:

    Qt Code:
    1. "[...] usercreationdialog.cpp:13: error: no matching function for call to 'UserCreationDialog::connect(UserCreationDialog*, const char*, UserConfiguration**, const char*)' connect(this, SIGNAL(updateUserConfig()),&uconf,SLOT(update()));"
    To copy to clipboard, switch view to plain text mode 
    ^

    UserCreationDialog.h
    Qt Code:
    1. #ifndef USERCREATIONDIALOG_H
    2. #define USERCREATIONDIALOG_H
    3. #include <QDialog>
    4.  
    5. class UserConfiguration;
    6.  
    7. namespace Ui {
    8. class UserCreationDialog;
    9. }
    10.  
    11. class UserCreationDialog : public QDialog
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit UserCreationDialog(QWidget *parent = 0);
    17. ~UserCreationDialog();
    18.  
    19. private slots:
    20. void on_buttonBox_accepted();
    21.  
    22. private:
    23. Ui::UserCreationDialog *ui;
    24. UserConfiguration *uconf;
    25. QSqlDatabase* fv_db;
    26.  
    27. signals:
    28. void updateUserConfig();
    29. };
    30.  
    31. #endif // USERCREATIONDIALOG_H
    To copy to clipboard, switch view to plain text mode 

    UserCreationDialog.cpp
    Qt Code:
    1. #include "usercreationdialog.h"
    2. #include "ui_usercreationdialog.h"
    3. #include "userconfiguration.h"
    4.  
    5. UserCreationDialog::UserCreationDialog(QWidget *parent) :
    6. QDialog(parent),
    7. ui(new Ui::UserCreationDialog)
    8. {
    9. ui->setupUi(this);
    10.  
    11. connect(this, SIGNAL(updateUserConfig()),&uconf,SLOT(update()));
    12. }
    13.  
    14. UserCreationDialog::~UserCreationDialog()
    15. {
    16. delete ui;
    17. }
    18.  
    19. void UserCreationDialog::on_buttonBox_accepted()
    20. {
    21. QString uid = ui->userIDLineEdit->text();
    22. QString pw = ui->passwordLineEdit->text();
    23. writeUserToDb(uid,pw, *fv_db);
    24. emit updateUserConfig();
    25. close();
    26. }
    To copy to clipboard, switch view to plain text mode 

    Some irrelevant code is left out from the shown code above.

    // Leutzig

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: "no matching function for call to 'UserCreationDialog::Connect(..."

    "uconf" already is a pointer, the & in your connect() call makes it a pointer to a pointer.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: "no matching function for call to 'UserCreationDialog::Connect(..."

    Thanks anda_skoa


    Added after 1 33 minutes:


    I actually have a different problem with my connect(). I got rid of the error before but now my application crashes when it reaches the connect(), and I get the message "The program has unexpectedly finished". Am I connecting my signal and slot correctly or?

    UserCreationDialog.h
    Qt Code:
    1. #ifndef USERCREATIONDIALOG_H
    2. #define USERCREATIONDIALOG_H
    3.  
    4. #include <QDialog>
    5. #include "dbinterface.h"
    6.  
    7. class UserConfiguration;
    8.  
    9. namespace Ui {
    10. class UserCreationDialog;
    11. }
    12.  
    13. class UserCreationDialog : public QDialog
    14. {
    15. Q_OBJECT
    16.  
    17. public:
    18. explicit UserCreationDialog(QWidget *parent = 0);
    19. ~UserCreationDialog();
    20.  
    21. private slots:
    22. void on_buttonBox_accepted();
    23.  
    24. private:
    25. Ui::UserCreationDialog *ui;
    26. UserConfiguration *uconf;
    27. QSqlDatabase* fv_db;
    28.  
    29. signals:
    30. void updateUserConfig();
    31. };
    32.  
    33. #endif // USERCREATIONDIALOG_H
    To copy to clipboard, switch view to plain text mode 

    UserCreationDialog.cpp
    Qt Code:
    1. #include "usercreationdialog.h"
    2. #include "ui_usercreationdialog.h"
    3. #include "userconfiguration.h"
    4.  
    5. UserCreationDialog::UserCreationDialog(QWidget *parent) :
    6. QDialog(parent),
    7. ui(new Ui::UserCreationDialog)
    8. {
    9. ui->setupUi(this);
    10.  
    11. connect(this, SIGNAL(updateUserConfig()), uconf, SLOT(updateUC()));
    12. }
    13.  
    14. UserCreationDialog::~UserCreationDialog()
    15. {
    16. delete ui;
    17. }
    18.  
    19. void UserCreationDialog::on_buttonBox_accepted()
    20. {
    21. QString uid = ui->userIDLineEdit->text();
    22. QString pw = ui->passwordLineEdit->text();
    23. writeUserToDb(uid,pw, *fv_db);
    24. emit updateUserConfig();
    25. delete this;
    26. }
    To copy to clipboard, switch view to plain text mode 

    The slot updateUConf() is found in the UserConfiguration class, so no need to show that.

    // Leutzig
    Last edited by Leutzig; 12th April 2016 at 14:11.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: "no matching function for call to 'UserCreationDialog::Connect(..."

    And where do you set the value of "uconf" that is used in your connect() statement? As far as I can see in your code, it is an uninitialized pointer.

  5. #5
    Join Date
    Oct 2015
    Posts
    28
    Thanks
    10
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: "no matching function for call to 'UserCreationDialog::Connect(..."

    That's right, I haven't initialized the pointer. Thanks

    // Leutzig
    Last edited by Leutzig; 12th April 2016 at 21:59.

Similar Threads

  1. Replies: 1
    Last Post: 20th November 2015, 10:02
  2. Replies: 2
    Last Post: 26th November 2013, 16:48
  3. Replies: 2
    Last Post: 26th October 2013, 05:40
  4. Replies: 2
    Last Post: 23rd May 2012, 15:07
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.