Results 1 to 2 of 2

Thread: QMetaObject::connectSlotsByName: No matching signal

  1. #1
    Join Date
    Feb 2016
    Posts
    7
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QMetaObject::connectSlotsByName: No matching signal

    Hi,

    I'm not using qt designer for this project, I'm doing it all by code. I'm having problems with my signals & slots. I have simple ones working for my mainwindow (exit, etc) but in a dialog window I'm trying to attach 3 slider signals, 1 lineedit and 1 button to 5 functions. All of them are receiving the following error:

    QMetaObject::connectSlotsByName: No matching signal for on_sizeslider_valuechanged(int)
    QMetaObject::connectSlotsByName: No matching signal for on_skillslider_valuechanged(int)
    QMetaObject::connectSlotsByName: No matching signal for on_texslider_valuechanged(int)
    QMetaObject::connectSlotsByName: No matching signal for on_enterplayername_textedited(QString)
    QMetaObject::connectSlotsByName: No matching signal for on_acceptbutton_clicked()
    Here's the relevant code from my .h:
    Qt Code:
    1. public slots:
    2. void on_sizeslider_valuechanged(int value);
    3. void on_skillslider_valuechanged(int value);
    4. void on_texslider_valuechanged(int value);
    5.  
    6. void on_enterplayername_textedited(const QString &arg1);
    7. void on_acceptbutton_clicked();
    To copy to clipboard, switch view to plain text mode 

    And the .cpp:
    Qt Code:
    1. //slots (these are at the end of the constructor)
    2. QObject::connect(acceptbutton, SIGNAL(clicked()),this, SLOT(on_acceptbutton_clicked()));
    3. QObject::connect(sizeslider, SIGNAL(valueChanged(int)), this, SLOT(on_sizeslider_valuechanged(int value)));
    4. QObject::connect(namebox, SIGNAL(textEdited(QString)), this, SLOT(on_enterplayername_textedited(const QString)));
    5. QObject::connect(texslider, SIGNAL(valueChanged(int)), this, SLOT(on_texslider_valuechanged(int)));
    6. QObject::connect(skillslider, SIGNAL(valueChanged(int)), this, SLOT(on_skillslider_valuechanged(int)));
    7.  
    8. }
    9. void Dialog::on_sizeslider_valuechanged(int value){
    10.  
    11. if (value == 1) {
    12. sizeoptions->setText("Small");
    13. }
    14. if (value == 2) {
    15. sizeoptions->setText("Medium");
    16. }
    17. if (value == 3) {
    18. sizeoptions->setText("Large");
    19. }
    20. if (value == 4) {
    21. sizeoptions->setText("XLarge");
    22. }
    23.  
    24. //sizechoice = value;
    25. }
    26.  
    27. void Dialog::on_skillslider_valuechanged(int value){
    28.  
    29. if (value == 1) {
    30. skilloptions->setText("Shrink & Boost");
    31. }
    32. if (value == 2) {
    33. skilloptions->setText("Gravity Gun");
    34. }
    35. if (value == 3) {
    36. skilloptions->setText("Tron");
    37. }
    38.  
    39. //skillchoice = value;
    40. }
    41.  
    42. void Dialog::on_texslider_valuechanged(int value){
    43.  
    44. if(value == 1){
    45. textcubeimg->setPixmap(QPixmap("checkertexture150x125.png"));
    46. }
    47.  
    48. if(value == 2){
    49. textcubeimg->setPixmap(QPixmap("checkertexturepink150x125.png"));
    50. }
    51.  
    52. if(value == 3){
    53. textcubeimg->setPixmap(QPixmap("checkertextureblue150x125.png"));
    54. }
    55.  
    56. //texchoice = value;
    57. }
    58.  
    59. void Dialog::on_enterplayername_textedited(const QString &arg1){
    60.  
    61. playername = arg1;
    62. }
    63.  
    64. void Dialog::on_acceptbutton_clicked(){
    65. qDebug() << playername;
    66. this->close();
    67. }
    To copy to clipboard, switch view to plain text mode 

    Upon running the code, when the dialog window is triggered I receive the following error (for only one of my slots this time):
    QObject::connect: No such slot Dialog:: on_sizeslider_valuechanged(int value) in ..\GUINew\dialog.cpp:115
    QObject::connect: (receiver name: 'Dialog')
    I don't know why, since the function is clearly there and the name is exactly the same. Additionally, the function for the acceptbutton seems to actually be working (the window exits), as does the enterplayername function (using qdebug I can see it is outputting the correct user input). The sliders however either do nothing (sizeslider) or cause the program to crash (skillslider, texslider).

    I've tried clean/build/qmake and it hasn't worked. If anyone could shed some light on the situation it'd be appreciated. Thanks!

  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: QMetaObject::connectSlotsByName: No matching signal

    That has already been answered hours ago: http://www.qtcentre.org/threads/6529...045#post288045

    Don't you think it would be better to check answers to your older questions before posting basically the same question again?

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 26th November 2014, 17:52
  2. Avoid QMetaObject::connectSlotsByName warning
    By qt_developer in forum Qt Programming
    Replies: 1
    Last Post: 19th March 2014, 14:30
  3. Replies: 7
    Last Post: 28th November 2013, 06:03
  4. connectSlotsByName and clicked()
    By becrux in forum Qt Programming
    Replies: 5
    Last Post: 2nd December 2009, 08:05
  5. Replies: 2
    Last Post: 8th November 2007, 21:23

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.