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 write custom Qt widget in pure C++, compile it and use in
I'm writing a custom widget that requires some supporting javascript code that I need
I am making a custom widget that I would like to use in multiple
Can anyone tell me how I can execute my custom jQuery code when Drupal's
How can I protect my web server, if I run custom users code on
How can I set a custom filter in my code to ignore accents and
I'm having trouble implementing a QListWidget with custom items that can be reordered by
I have implemented a custom CellRenderer in PyGTK that can take longer to render
I'm trying to use a custom widget: gwtupload with it's custom handlers. The handlers

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.