Action Button in MenuBar
-
@jsulm It does not work though, I was trying my hands on it but I'm stacked. All what I see online is below which works fine.
self.ui.actionClose.triggered.connect(qApp.exit)
-
@LT-K101 Yes, is actionAdd_New triggered, so it calls window1?
You can simply print something inside window1 to see whether it is called... -
@jsulm It is a QMainWindow with QStackedWidget pages in it. All what I want to do is show the first QStackedWidget page when i trigger the Qmenu action Button.
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QMainWindow, QAction,qApp,QApplication class AdminForm(QtWidgets.QMainWindow): def __init__(self, mainMenu): super(AdminForm, self).__init__() self.mainMenu = mainMenu self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionClose.triggered.connect(qApp.exit) self.ui.actionAdd_New_Employee.triggered.connect(self.window1) def window1(self): self.ui.stackedWidget.setCurrentWidget(self.ui.First_page)
-
@jsulm It is a QMainWindow with QStackedWidget pages in it. All what I want to do is show the first QStackedWidget page when i trigger the Qmenu action Button.
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QMainWindow, QAction,qApp,QApplication class AdminForm(QtWidgets.QMainWindow): def __init__(self, mainMenu): super(AdminForm, self).__init__() self.mainMenu = mainMenu self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionClose.triggered.connect(qApp.exit) self.ui.actionAdd_New_Employee.triggered.connect(self.window1) def window1(self): self.ui.stackedWidget.setCurrentWidget(self.ui.First_page)
@LT-K101 said in Action Button in MenuBar:
AdminForm
I asked about Window1 which you're trying to show in your window1! Why do you show AdminForm? And why do you have a completely different implementation of window1 in AdminForm than the one you posted before? This is really confusing...
-
@LT-K101 said in Action Button in MenuBar:
AdminForm
I asked about Window1 which you're trying to show in your window1! Why do you show AdminForm? And why do you have a completely different implementation of window1 in AdminForm than the one you posted before? This is really confusing...
-
@LT-K101 said in Action Button in MenuBar:
AdminForm
I asked about Window1 which you're trying to show in your window1! Why do you show AdminForm? And why do you have a completely different implementation of window1 in AdminForm than the one you posted before? This is really confusing...
-
@jsulm This is the GUI of my program, when I click on Add New Staff a pages should open. I'm really confused about how to implement this.
@LT-K101 So, unlike you wrote at the beginning you want to show another page when clicking one of the menus (not another window).
So, then let go step by step:- window1() is called, right?
- What happens then? Nothing? Or is wrong page shown?
- What if you use setCurrentIndex instead of setCurrentWidget?
-
@LT-K101 So, unlike you wrote at the beginning you want to show another page when clicking one of the menus (not another window).
So, then let go step by step:- window1() is called, right?
- What happens then? Nothing? Or is wrong page shown?
- What if you use setCurrentIndex instead of setCurrentWidget?