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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:20:53+00:00 2026-05-16T00:20:53+00:00

How can I in code of the custom Qt widget know that it is

  • 0

How can I in code of the custom Qt widget know that it is currently instantiated in Qt designer?

Use case:

I build a complex custom widget that has several child widgets like QPushButton, QLabel etc.

As application logic require, when widget is created most of those sub component are not visible but in design time when I put it on a form I would like to see them.

To be able to play with style sheet at design time.
Currently what I get is a empty is only a result of constructor – minimal view (actually empty in my case).

What I am looking for is to be able to do something like

MyQWidget::(QWidget *parent)
{
 ....
   if(isRunningInDesigner())
   {
      myChildWidget1->setVisible(true);
      myChildWidget2->setVisible(true);
      myChildWidget3->setVisible(true);
   }
   else
   {
      myChildWidget1->setVisible(false);
      myChildWidget2->setVisible(false);
      myChildWidget3->setVisible(false);
   }
....
}

So what should I put in to this bool isRunningInDesigner() ?

  • 1 1 Answer
  • 1 View
  • 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-16T00:20:54+00:00Added an answer on May 16, 2026 at 12:20 am

    From the Qt Designer manual:

    To give custom widgets special behavior in Qt Designer, provide an implementation of the initialize() function to configure the widget construction process for Qt Designer specific behavior. This function will be called for the first time before any calls to createWidget() and could perhaps set an internal flag that can be tested later when Qt Designer calls the plugin’s createWidget() function.

    Those are methods from the QDesignerCustomWidgetInterface plugin interface. In short: you tell the widget to behave differently when Qt Designer asks your plugin to create instances of your custom widget.

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

Sidebar

Related Questions

I created a custom widget for wordpress. But I can only use it once.
Can I setup a custom MIME type through ASP.NET or some .NET code? I
I have a custom XML file format which can contain blocks of code within
In IIS I can configure my custom error pages. For each HTTP Error code
Can VBA code instantiate and use .NET objects? The specific class I'm interested in
I've tried to create a custom widget plugin for QT Designer following this (
Is there a program or API I can code against to extract individual files
Python is pretty clean, and I can code neat apps quickly. But I notice
Surprisingly as you get good at vim, you can code even faster than standard
Can source code examples be kept in a SQL database while retaining all formatting

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.