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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:55:37+00:00 2026-06-10T18:55:37+00:00

I have a class declared using this form MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)

  • 0

I have a class declared using this form

MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
{
    ...
}

I want to refactor it with this form looking like this :

class MainWindow : QMainWindow, ui 
{
    MainWindow(QWidget *parent)
    {
        ...
    }
}

But I removed the parameters that were in the first form. What do this parameters mean ?

How to keep them in the second form ? Please explain me the first syntax (or point to tutorial). I don’t understand inheritance with parameters.

EDIT:

I understand the problem now, the class was initialised in a separate .h file which I did not saw at first look. I thought : after the method definition was inheritance operator, whereas it is member initialization operator.

  • 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-10T18:55:39+00:00Added an answer on June 10, 2026 at 6:55 pm

    This is the implementation of a constructor, calling a base class constructor and initializind a data member in the initialization list:

    MainWindow(QWidget *parent) :
            QMainWindow(parent),   // call base class constructor
            ui(new Ui::MainWindow) // initialize data member ui
    {
        ...
    }
    

    It is very likely that the class inherits from QMainWindow and has a Ui::MainWindow* data member called ui. Your second code snippet seems like an incorrect attempt to declare a class. There is no “inheritance with parameters” as such, so you cannot do what you ask about.

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

Sidebar

Related Questions

I have a PaartialView declared like this: @model IEnumerable<mvc1.Models.ProjectDetailModel> @using (Html.BeginForm()) <form method=get action=EditProject
Here I have declared another virtual function in Derived class. #include <iostream> using namespace
I have an abstract method in a base class declared like so... public abstract
I have this one class: say InterClass . This class is declared in say,
Using ARC, I have a declared property of the following form: @property (nonatomic, strong)
I have a class declared as: public class Foo<T> : Panel where T :
Let's say I have a class declared as: @class SomeClass @interface SomeClass: NSObject {
I have declared a class as class DCFrameListener : public FrameListener, public OIS::MouseListener, public
WorkAround: I have declared a class level Public static variable and initialized with a
I have a class called Metadata, which is declared within the namespace A::B::C ,

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.