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 8977311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:20:31+00:00 2026-06-15T19:20:31+00:00

I was trying to figure out how this code will loke like in plain

  • 0

I was trying to figure out how this code will loke like in plain C++ without any dependency so I was using the moc compiler but apparently I’m wrong.

moc always returns

main.cpp:0: Note: No relevant classes found. No output generated.

the code is

#include <QApplication>
#include <QWidget>
#include <QPushButton>

class MyButton : public QWidget
{
 public:
     MyButton(QWidget *parent = 0);
};

MyButton::MyButton(QWidget *parent)
    : QWidget(parent)
{   
  QPushButton *quit = new QPushButton("Quit", this);
  quit->setGeometry(50, 40, 75, 30);

  connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
}


int main(int argc, char *argv[])
{
  QApplication app(argc, argv);  

  MyButton window;

  window.resize(250, 150);
  window.move(300, 300);
  window.setWindowTitle("button");
  window.show();

  return app.exec();
}

from http://www.zetcode.com/gui/qt4/firstprograms/

In general terms I’m interested in creating my own signal slot system using only the C++ standard library ( no boost signal, no QT, no nothing else ) so I’m doing this for research purpose and I’m only interested on the infrastructure about signals and slots.

Thanks.

  • 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-06-15T19:20:32+00:00Added an answer on June 15, 2026 at 7:20 pm

    Add the Q_OBJECT macro to the private section of your class, so moc converts it.

    class MyButton : public QWidget
    {
     Q_OBJECT
     public:
         MyButton(QWidget *parent = 0);
    };
    

    Here is what the documentation says.

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

Sidebar

Related Questions

Trying to figure out this pseudo code. The following is assumed.... I can only
I'm trying to figure out why this code won't compile. I have interface A
I'm trying to code this site (keyword trying) and I'm trying to figure out
I am trying to figure out how to simplify this piece of code. The
I am trying to figure out why I get this error. My code is
I'm getting really tired of trying to figure out why this code works in
I cannot figure out why this code will not work. Can anyone help? I
I'm trying to figure out how i can implement this code into my existing
I am trying to figure out if this code is updating the UI on
So I spent 2 hours trying to figure this out, minimizing the code as

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.