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

  • Home
  • SEARCH
  • 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 7277805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:47:26+00:00 2026-05-28T22:47:26+00:00

I am trying to a create a command class hierarchy. Basically each command will

  • 0

I am trying to a create a command class hierarchy. Basically each command will be bound to a QAction. Once the action is triggered, it will call a virtual method.

Here is the code:

class Command  : QObject
{
    Q_OBJECT

public:
    Command(QWidget *parent);

public slots:
    virtual void execute();

protected:
    QAction *commandAct;
};

Command::Command(QWidget *parent)
{
    commandAct = new QAction(parent);
    parent->addAction(commandAct);
    connect(commandAct,SIGNAL(triggered()),this,SLOT(execute()));
}

QAction *Command::getAction()
{
    return commandAct;
}

Now if I derive a class and override the execute method, will it be called like it is supposed to be?

I need this to work cross platform.

  • 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-28T22:47:27+00:00Added an answer on May 28, 2026 at 10:47 pm

    Yes, overriding virtual slots works just with every other virtual method. In the end, the signal/slot connect is just a method call, which can be either virtual or non-virtual.

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

Sidebar

Related Questions

I am trying to create a generic Exists() Command class that is able to
First, context: I'm trying to create a command-line-based tool (Linux) that requires login. Accounts
I am trying to create a WPF application that takes command line arguments. If
I'm trying to create an app for Android that simply sends a command to
I am trying to create a custom command button that defaults width and height
I'm trying to create and compile a simple Objective-C program from the command line.
I'm trying to create my own class template for Visual Studio called Public Class.
I am trying to create a simple C++ class and a Matlab mex file.
I am trying to create a jar using the following command on a RHEL
I am trying to create a jar file off of a class and xml

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.