Results 1 to 5 of 5

Thread: No such slot

  1. #1
    Join Date
    May 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: No such slot

    I am obtaining the following error when I run this program:

    "QObject::connect: No such slot MainWindow::read_deck(const QString &fileName) in ../Card_Probability_Calc/mainwindow.cpp:232
    The program has unexpectedly finished."

    Qt Code:
    1. void MainWindow::create_actions()
    2. {
    3. readAction = new QAction(tr("Read new deck"), this);
    4. QObject::connect(readAction, SIGNAL(triggered()), this, SLOT(read_deck(const QString &fileName))); *** point of error
    5.  
    6. refreshAction = new QAction(tr("Reload current deck"), this);
    7. QObject::connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh_deck()));
    8.  
    9. //saveAction = new QAction(tr("Save results to file"), this);
    10. // QObject::connect(saveAction, SIGNAL(triggered()), this, SLOT(save_analysis()));
    11.  
    12. analyzeAction = new QAction(tr("Perform deck analysis"), this);
    13. QObject::connect(analyzeAction, SIGNAL(triggered()), this, SLOT(analyze_deck()));
    14.  
    15. QObject::connect(exitAction,SIGNAL(triggered()), qApp, SLOT(quit()));
    16.  
    17. QObject::connect(btns_a[0], SIGNAL(QPushButton::clicked()), this, SLOT(m_b()));
    18. QObject::connect(btns_a[1], SIGNAL(QPushButton::clicked()), this, SLOT(m_g()));
    19.  
    20. QObject::connect(btns_a[2], SIGNAL(QPushButton::clicked()), this, SLOT(b_m()));
    21. QObject::connect(btns_a[3], SIGNAL(QPushButton::clicked()), this, SLOT(b_g()));
    22.  
    23. QObject::connect(btns_a[4], SIGNAL(QPushButton::clicked()), this, SLOT(g_m()));
    24. QObject::connect(btns_a[5], SIGNAL(QPushButton::clicked()), this, SLOT(g_b()));
    25. }
    To copy to clipboard, switch view to plain text mode 


    slot:
    Qt Code:
    1. void MainWindow::read_deck(const QString &fileName)
    2. {
    3. list_sizes[0] = 0;
    4. list_sizes[1] = 0;
    5. list_sizes[2] = 0;
    6. int monster_count = 0;
    7. int spell_count = 0;
    8. int trap_count = 0;
    9. current_file = fileName;
    10. std::string file = fileName.toStdString();
    11. std::string current_card;
    12. QString current_card_q;
    13. std::ifstream infile("file.txt");
    14. int passed_main = 0;
    15. std::string line;
    16. while(std::getline(infile, line))
    17. {
    18. if(line == "#main")
    19. {
    20. passed_main++;
    21. }
    22. else if(line == "#extra")
    23. {
    24. passed_main++;
    25. }
    26. else if(passed_main == 1)
    27. {
    28. current_card = read_name(line);
    29. current_card_q = QString::fromUtf8(current_card.c_str());
    30. new_item->setText((current_card_q));
    31. mn_lst->QListWidget::addItem(new_item);
    32. list_sizes[0]++;
    33. read_type(current_card);
    34. }
    35. }
    36. }
    To copy to clipboard, switch view to plain text mode 


    slots def.
    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MainWindow();
    7.  
    8. std::string read_name(const std::string idnum);
    9. int read_number(const std::string idnum);
    10. int read_type(const std::string idnum);
    11. QListWidgetItem *items_a[10];
    12. // void save_analysis(const std::string &fileName);
    13. public slots:
    14. void analyze_deck();
    15. void read_deck(const QString &fileName);
    16. void refresh_deck();
    17.  
    18. void m_b();
    19. void m_g();
    20.  
    21. void b_m();
    22. void b_g();
    23.  
    24. void g_m();
    25. void g_b();
    26. .
    27. .
    28. .
    To copy to clipboard, switch view to plain text mode 


    I have already forced the _moc file to be redone.


    Added after 28 minutes:


    Additionally, all of the connects for the pushbuttons are also non-functional
    Last edited by ABZB; 13th May 2013 at 16:45.

  2. #2
    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: No such slot

    Don't put variable names in connect() statements. Only types are allowed. Also think where should the value for a slot parameter come from if the signal it connects to doesn't carry any values.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: No such slot

    Ok, I changed the one function that required a parameter. I am still getting an error. non of my connections are connecting.

    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:245
    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:246
    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:248
    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:249
    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:251
    QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:252

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No such slot

    In lines with connect change QPushButton::clicked() to clicked().

  5. #5
    Join Date
    May 2013
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: No such slot

    Thanks!!

Similar Threads

  1. Replies: 8
    Last Post: 7th November 2012, 14:10
  2. Replies: 2
    Last Post: 26th August 2011, 08:51
  3. Slot
    By mickey in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2006, 18:51
  4. Slot
    By mickey in forum Qt Programming
    Replies: 13
    Last Post: 4th June 2006, 12:18
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.