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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:10:10+00:00 2026-05-27T17:10:10+00:00

I’ve designed some construction like this: template<class Ui_Class> class Base_Dialog : virtual public QDialog,

  • 0

I’ve designed some construction like this:

template<class Ui_Class>
class Base_Dialog : virtual public QDialog, protected Ui_Class
{

protected:

    QDialog* caller_;

public:
    template<class Implementation>
    Base_Dialog(Implementation*const & imp,QDialog *caller,QWidget* parent = nullptr);

};

template<class Ui_Class>
template<class Implementation>
Base_Dialog<Ui_Class>::Base_Dialog(Implementation*const& imp,QDialog *caller,QWidget* parent):
    QDialog(parent),
    caller_(caller)
{
    setupUi(imp);
}

I’m using it like so:

class My_Class : public **Base_Dialog<Ui::My_Class>**
{
    Q_OBJECT


public slots:
    void display_me()
    {/*THIS IS NOT GETTING CONNECTED*/
        QMessageBox::warning(this,"Aha!","Aha!");
    }

public:
    explicit My_Class(QDialog* caller = nullptr,QWidget *parent = nullptr);

};

Line_Counter::Line_Counter(QDialog* caller,QWidget *parent) :
    Base_Dialog(this,caller,parent)

{
    //setupUi(this);//THIS WORKS BUT I'D RATHER CALL IT FROM Base_Dialog


}

this above construct is suppose to ease and simplify the way of inheriting from QDialog and from Ui class. And this works, except that when slots and signals are introduced in my class the base class for some reason doesn’t see them (slots/signals). If I call setupUi in My_Class ctor everything works correctly but I’d prefer to call it in Base_Class. Is there a way to do it?

  • 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-27T17:10:11+00:00Added an answer on May 27, 2026 at 5:10 pm

    The constructor for lineCounter should be renamed to My_Class as well, am I right?

    The reason for this behavior is that the meta object returned in constructor of Base_Dialog from virtual const QMetaObject * metaObject() const is meta-object for Base_Dialog, as at this stage it is not yet instance of My_Class instance. My_CLass overrides this virtual method (invisibly in Q_OBJECT macro) but only after My_Class constructor code starts to execute – means after Base_Dialog code is finished. Signals and slots internally use meta-objects while connecting, so it seems this way it will not work.

    Summarizing – you cannot do it, because constructor of Base_Dialog doesn’t know that My_Class instance is being created and therefore cannot have acces to any of it’s contents.

    Sometimes this problem can be bypassed using CRTP, but in this case I have no idea if it’s aplicable. I would rather opt for doing it Qt’s way – call setupUi from My_Class constructor.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.