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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:49:29+00:00 2026-05-24T07:49:29+00:00

Hello PyQt/PySide experts, I am a newbie to both PyQt/PySide and desktop application development

  • 0

Hello PyQt/PySide experts,

I am a newbie to both PyQt/PySide and desktop application development (I’m a web developer).

I have a question about how you should navigate among different views in a PyQt/PySide application.

Suppose my app has views (i.e. like pages in a web app) “TEST1″(default) and “TEST2”, and I want to switch between them by clicking on the corresponding toolbar item.

I thought I could use QMainWindow.setCentralWidget() to set the requested view each time the toolbar button is clicked, but is this a normal way to navigate among different views in PyQt/PySide?

For your reference, I will post an example code to illustrate the above:

#!/usr/bin/env python

import sys
from PySide import QtCore
from PySide.QtCore import *
from PySide.QtGui import *

class MainWindow(QMainWindow):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        # toolbar action 1
        self.test1_action = QAction(QIcon('icons/test1.png'), 'Test 1', self)
        self.test1_action.triggered.connect(self.show_test1_view)

        # toolbar action 2
        self.test2_action = QAction(QIcon('icons/test2.png'), 'Test 2', self)
        self.test2_action.triggered.connect(self.show_test2_view)

        # create toolbar
        self.toolbar = self.addToolBar('Actions')
        self.toolbar.addAction(self.test1_action)
        self.toolbar.addAction(self.test2_action)

        # default view is test1, so call the method to set the central widget to "test1" view.
        self.show_test1_view()

    # switch to "test1" view - just a simple label here.
    def show_test1_view(self):
        self.test1_view = QLabel('TEST1 VIEW')
        self.setCentralWidget(self.test1_view)

    # switch to "test2" view - just a simple label here.
    def show_test2_view(self):
        self.test2_view = QLabel('TEST2 VIEW')
        self.setCentralWidget(self.test2_view)

app = QApplication(sys.argv)

window = MainWindow()
window.show()

app.exec_()
sys.exit()

Thank you in advance…!

  • 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-24T07:49:30+00:00Added an answer on May 24, 2026 at 7:49 am

    stackedwidget might do the trick

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

Sidebar

Related Questions

Hello i'm doing a application in php, and i have a list of items
Hello ever one I want to ask a question about file opening.I want to
Hello we have an SQL server application running over a low bandwith connection. We
Hello guys i have a small problem at my console application i have a
Hello I have asp mvc view page, <%@ Page Language=C# Inherits=System.Web.Mvc.ViewPage<System.Drawing.Color[,]> %> how I
Hello everybody i have asp.net mvc4 application where i made countdown something like this:
Hello good morning everyone, i have an iphone app which is still in development
Hello as i have to restrict user from installing the application on more than
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello all i am working on a project in which i have a webpage

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.