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

  • Home
  • SEARCH
  • 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 4123644
In Process

The Archive Base Latest Questions

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

I have a tab widget created with 3 tabs in it. I need to

  • 0

I have a tab widget created with 3 tabs in it. I need to emit signals when I change the tab, Looking at the pyQt documentation currentChanged() is the signal that is emitted on Changing the tab but it does not work for me. So need your help on understanding the same,

MY code is as follows:

main_tab_widget = QTabWidget()

    #Creating Tabs
    self.run_tab = QWidget()
    self.cc_tab = QWidget()
    self.result_tab = QWidget()

    #Adding Tabs to Tab Widget
    main_tab_widget.addTab(self.run_tab, "RUN")
    main_tab_widget.addTab(self.cc_tab, "Config Creator")
    main_tab_widget.addTab(self.result_tab, "Result")

    #Layout Creation
    main_layout = QVBoxLayout()
    main_layout.addWidget(main_tab_widget)

    self.connect(self.cc_tab, SIGNAL('currentChanged(int)'), self.pseudofunction)
    self.RunTab()
    self.setLayout(main_layout)
    #self.configcreatortab()
    #self.resulttab()

def pseudofunction(self):
    print 'Inside Pseudo Function'
  • 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-20T23:38:16+00:00Added an answer on May 20, 2026 at 11:38 pm

    You’re attempting to wire up the currentChanged signal from the wrong object. main_tab_object is the QTabWidget that emits this signal, but you’re attempting to wire up this signal from self.cc_tab, a QWidget in one of the tabs.

    Replace the line

        self.connect(self.cc_tab, SIGNAL('currentChanged(int)'), self.pseudofunction)
    

    with

        self.connect(main_tab_widget, SIGNAL('currentChanged(int)'), self.pseudofunction)
    

    EDIT: There is no way to use the signals/slots mechanism to connect a different function to each tab of a QTabWidget. If you want to call different functions when different tabs are selected, you’ll have to write another function that calls the relevant function depending on which tab was selected. For example:

    def selector(self, selected_index):
        if selected_index == 0:
            self.some_function_for_run_tab()
        elif selected_index == 1:
            self.some_function_for_cc_tab()
        elif selected_index == 2:
            self.some_function_for_result_tab()
    

    You then connect the currentChanged signal of the QTabWidget to this function.

    You are correct that QTabBar also has the currentChanged signal, but your usage of it in your second comment, by replacing QWidget() with QTabBar() in your code above, will not achieve what you want.

    A QTabBar acts only as the bar that contains a collection of tabs. (In fact, the QTabWidget uses a QTabBar internally for its tab bar.) So, putting a QTabBar within a QTabWidget gives you tabs within tabs. I don’t believe this is what you want. Furthermore I suspect you’re not adding any tabs to the QTabBars. The QTabBars do have the currentChanged signal, and your code will correctly connect these signals, but these signals will never fire because the QTabBars contain no tabs to change.

    The fact that these QTabBars may themselves be inside a QTabWidget is irrelevant. They only see changes to their own set of tabs and hence can only fire signals for changes to their own set of tabs.

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

Sidebar

Related Questions

I have a tab page that should be hidden if a property (BlahType) is
Modern browsers have multi-tab interface, but JavaScript function window.showModalDialog() creates a modal dialog that
So I have a form with lots of controls that all have a tab
As per the android developer docs for creating tab UI you need to have
Alright, so I followed the Tab Widget tutorial to create some tabs for my
I have a Tab Control with multiple Tab Pages. I want to be able
I have a tab navigator control and I would like to make all of
I have 2 tab items. In tab No.1 I have a control which corresponds
I have a tab delimited file where each record has a timestamp field in
I have a huge tab separated file which I want to sort on its

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.