Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6172399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:23:12+00:00 2026-05-23T23:23:12+00:00

Problem is that I keep getting the ‘No Such Slot’ runtime error in Qt

  • 0

Problem is that I keep getting the ‘No Such Slot’ runtime error in Qt Creator every time I launch a ‘settings’ window from my main window. I’ve found Qt to be quite counter-intuitive so far and this slots ‘n signals concept seems a bit of a stretch from simply passing vars or function calls. Basically, I have menu with a settings option, that when clicked, opens a settings window which needs to grab a double from the user and update a var in the main window.

SettingsWindow.h

class SettingsWindow : public QWidget
{
      Q_OBJECT
  public:
      SettingsWindow(QWidget *parent = 0);
  signals:
      void ValChanged(double newVal);
  public slots:
      void Accept();
  private:
      QLineEdit *le1;
};

The settings window has an accept button which calls Accept() which emits the ValChanged signal with newVal set as the user input in le1 as a double.

SettingsWindow.cpp

void SettingsWindow::Accept(){
    emit ValChanged(le1->text().toDouble());
    this->close();
}

This settings window is called by the application’s main window: MainWindow

MainWindow.cpp

class MainWindow : public QMainWindow
{
      Q_OBJECT  
  public:
      MainWindow(QWidget *parent = 0);
  public slots:
      void SetVal(double x);
  private slots:
      void NewWindow();
  private:
      double theVal;
};

This main window has a menu which one would select settings from. This creates a new window with a field for one to enter a number.

MainWindow.cpp

void MainWindow::NewWindow()
{
    SettingsWindow *MySettings=new SettingsWindow(this);
    QObject::connect(MySettings, SIGNAL(ValChanged(double)), this, SLOT(SetVal(double)));
    MySettings->show();
    MySettings->raise();
}

void MainWindow::SetVal(double x){
    theVal = x;
}

My hope is that when the settings window is opened, the user can enter a val into the field which then emits the ValChanged Signal which sets theVal to the value specified by the user. Most of the time I saw an issue with people not including Q_OBJECT macro, but I’ve included it both times. Any suggestions on why this doesn’t work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:23:13+00:00Added an answer on May 23, 2026 at 11:23 pm

    The issue you are having is almost certainly due to a moc file not being recreated, a typo in your call to connect or a typo in the declaration of the slot in question.

    You may want to consider that this is a lot more work than necessary for getting input from a dialog. A simpler method would be to connect the “Accept” button clicked signal to a slot in main window and then fetch the value you want directly from the instance of the settings window through a getXXX() method.

    If you eventually have a settings dialog with a lot of values, instead of fetching each value through getters, have the “Accept” button signal return a structure with all the values as fields of that structure.

    I should mention that it looks like NewWindow() creates a new instance of SettingsWindow each time it is called. All of these instances will persist until the MainWindow is destroyed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem that I am having has to do with the need to keep
I keep getting the error Stream was not writable whenever I try to execute
One problem that I come across regularly and yet don't have a solution to
A problem that we need to solve regularly at my workplace is how to
I have a problem that confuses my users, being that although an item is
This has been a problem that I haven't been able to figure out for
I have the problem that an specific step in Ant can only be executed
I am having the problem that I cannot select a specific XML node which
He're an interesting problem that looks for the most Pythonic solution. Suppose I have
I had a problem that was partially solved. To explain it quickly : I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.