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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:06:52+00:00 2026-06-14T12:06:52+00:00

I have a MainWindow that looks like this: def __init__(self, parent = None): QMainWindow.__init__(self,

  • 0

I have a MainWindow that looks like this:

def __init__(self, parent = None):

    QMainWindow.__init__(self, parent)
    self.setupUi(self)
    self.showMaximized()

    menu=mainMenu.MainMenu()

    classification=classificationMain.ClassificationMain()

    self.stackedWidget.addWidget(menu)
    self.stackedWidget.addWidget(classification)

    self.stackedWidget.setCurrentWidget(menu)
    self.stackedWidget.showFullScreen()

    #connections

    menu.pushButton.clicked.connect(self.showClassification)
    classification.backButton.clicked.connect(self.showMainWindow)

def showClassification(self ):
    self.stackedWidget.setCurrentIndex(3)

def showMainWindow(self):
    self.stackedWidget.setCurrentIndex(2)

The MainWindows waits for signal from the rest of the dialogs. Now, the Classification dialog has another StackedWidget in it, since it works as a main window for an important part of the application. It looks like:

class ClassificationMain(QDialog, Ui_Dialog):

def __init__(self, parent = None):

    QDialog.__init__(self, parent)
    self.setupUi(self)
    choose=choosePatient.ChoosePatient()
    self.stackedWidget.addWidget(choose)
    self.stackedWidget.setCurrentWidget(choose)

Now, I want to reload the data inside ChoosePatient every time the button “Show Classification” from MainMenu is clicked, but now the data is loaded only once in the line classification=classificationMain.ClassificationMain() of MainWindow.

I was thinking I had to connect a slot inside ChoosePatient with the click of “Show Classification” button inside MainMenu, but I would need an instance of MainMenu, which is not possible.

How can a method of ChoosePatient can be execute every time the button in the “parent” window is clicked? (also, please tell me if this is not the right way to work with pyqt windows)

  • 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-14T12:06:53+00:00Added an answer on June 14, 2026 at 12:06 pm

    You need to save references to your composed widgets, and also to expose some public methods to the parents:

    class ClassificationMain(QDialog, Ui_Dialog):
    
        def __init__(self, parent = None):
    
            QDialog.__init__(self, parent)
            self.setupUi(self)
            self.chooseWidget=choosePatient.ChoosePatient()
            self.stackedWidget.addWidget(self.chooseWidget)
            self.stackedWidget.setCurrentWidget(self.chooseWidget)
    
        def reloadPatients(self):
            # whatever your operation should be on the ChoosePatient
            self.chooseWidget.reload()
    
    
    # MAIN WINDOW
    def __init__(self, parent = None):
        ...
        self.classification=classificationMain.ClassificationMain()
        self.stackedWidget.addWidget(self.classification)
        ...
        #connections
        menu.pushButton.clicked.connect(self.showClassification)
    
    def showClassification(self ):
        self.stackedWidget.setCurrentIndex(3)
        self.classification.reloadPatients()
    

    You could also just skip the reloadPatients method and connect to the ChoosePatient directly if you want:

    def showClassification(self ):
        self.stackedWidget.setCurrentIndex(3)
        self.classification.chooseWidget.reload()
    

    My personal opinion is to make your custom classes wrap up the internal functionality nicely so that you only need to interface with it over the custom class, and not dig into its internals. That way you can change how it works inside without breaking the main window.

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

Sidebar

Related Questions

I have a simple Window that looks like this: <Window x:Class=StackOverflowExample.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow
My application looks like this: main.py windows/ __init__.py mainwindow.py ... model/ __init__.py orders.py ...
I am using MVVM Light. I have created a window that looks like this:
I would like to have a QMainWindow that can change it's look at runtime,
I am writing a program with Qt that looks like this: The main window
I have a view that is loaded in the MainWindow.xib. It is just a
I have a main window, that opens another window. I want to close this
I have a class that inherits QMainWindow and I just want it to have
Problem is like this: I have two winapi application's. There is only one way
I have a MainWindow class that extends JFrame and is the only frame in

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.