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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:33:36+00:00 2026-06-18T03:33:36+00:00

I am loading a QMainWIndow base from a *.ui file. Also, i have a

  • 0

I am loading a QMainWIndow base from a *.ui file. Also, i have a custom widget i want to place somewhere on the form. Currently i put in the .ui file an empty QVBoxLayout named placeholder, and in the QMainWindow subclass do self.placeholder.addWidget(my_custom_widget)

The only thing i don’t like in this approach is that the empty layout does not have its own size. I can have a layout with one cell and with a dummy widget (QLabel for example) with the size i want, and replace this widget and then add my custom widget, but the method seems too much for me.

What is your approach for such a task?

I am using Python (PyQt4)

  • 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-18T03:33:37+00:00Added an answer on June 18, 2026 at 3:33 am

    Here is an easy little tutorial on how to promote a widget:

    1. Right click on the widget you are going to use as placeholder and select Promote To….

      Image Promote

    2. Fill in the Promoted Clases pop-up dialog fields:
      • Base Class Name: QWidget in this case.
      • Promoted Class Name: The class name you used to define the widget for which you are creating the placeholder, here it is MyWidget
      • Header File: /path/to/MyWidget.py is the path to the file in which MyWidget is placed. Image Path
    3. Once you click Add, the class is created and displayed, select it and click Promote. You are done promoting. Image Add
    4. Here is what you should see in your Object Inspector panel, the name of the class is no longer QWidget, it’s MyWidget instead.

      Image Promoted

    5. In the file at /path/to/MyWidget.py I have a class named MyWidget, and the content is something like this:

      #!/usr/bin/env python
      #-*- coding:utf-8 -*-
      
      from PyQt4 import QtGui
      
      class MyWidget(QtGui.QWidget):
          def __init__(self, parent=None):
              super(MyWidget, self).__init__(parent)
      
              self.labelHello = QtGui.QLabel(self)
              self.labelHello.setText("This is My Widget")
      
              self.layout = QtGui.QHBoxLayout(self)
              self.layout.addWidget(self.labelHello)
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

C# - Loading image from file resource in different assembly I have a PNG
while loading getfptex(got it from CTAN) batch file ,when i'm extracting this batch file
Loading a QImage object from a jpeg file fails when the application is linked
Loading images from thumbnails seems to have been covered ad nauseum but I just
Loading a CGImage or NSImage from a file using a standard image format (jpeg,
Makes loading custom images, after downloading put a watermark. Paperclip by default puts the
On loading the page I want to pass a value to my javascript function
While loading a Windows Form (C#), I'm trying to iterate through all controls. So
I have to add support for iPhone5 to my app. Currently the appdelegate uses
I am using Qt 4.8.4 and I have created a QMainWindow using Qt Designer

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.