Originally Posted by
anda_skoa
Right. Or a QSplitter as Ginsengelf said.
Again as Ginsengelf said, the idea about using a QStackWidget is to avoid having to do that.
Essentially you add your buttons to a
QButtonGroup and use the "id" argument to associate the page index on the stack widget side with the button.
You can then directly connect the buttongroup's buttonClicked(int) signal with the stackedwidget's setCurrentIndex(int) slot and are done.
Cheers,
_
Dear Anda_Skoa,
your suggestions seems very interesting and I tried to implement it with no luck. For now, I just skiped the QButtonGroup suggestion and I was focusing in the QStackWidget. So, in the main screen I have a left panel with a QVBoxLayout and on the right panel I have a QStackedWidget:
def UI(self):
#rightPanel = QVBoxLayout()
line.
setGeometry(QtCore.
QRect(213,
20,
20,
391)) line.
setFrameShape(QtWidgets.
QFrame.
VLine) line.
setFrameShadow(QtWidgets.
QFrame.
Sunken) line.setObjectName("line")
self.loadLeftPanel(leftPanel)
self.loadRightPanel(rightPanel)
mainScreen.addLayout(leftPanel)
mainScreen.addWidget(line)
mainScreen.addLayout(rightPanel)
rightPanel.setCurrentIndex(1)
self.setLayout(mainScreen)
self.show()
def UI(self):
mainScreen=QHBoxLayout()
leftPanel = QVBoxLayout()
#rightPanel = QVBoxLayout()
rightPanel = QStackedWidget()
line = QtWidgets.QFrame()
line.setGeometry(QtCore.QRect(213, 20, 20, 391))
line.setFrameShape(QtWidgets.QFrame.VLine)
line.setFrameShadow(QtWidgets.QFrame.Sunken)
line.setObjectName("line")
self.loadLeftPanel(leftPanel)
self.loadRightPanel(rightPanel)
mainScreen.addLayout(leftPanel)
mainScreen.addWidget(line)
mainScreen.addLayout(rightPanel)
rightPanel.setCurrentIndex(1)
self.setLayout(mainScreen)
self.show()
To copy to clipboard, switch view to plain text mode
Now the problem is in the "loadRightPanel" function. Looking at some example I have to add some widget (one for each page), provide a function for the UI specific for each stack and finally add the widget at the layout. This is what I did:
def loadRightPanel(rightPanel):
#stack3 =QWidget()
stack1UI(stack1)
stack2UI(stack2)
#stack3UI()
rightPanel.addWidget(stack1)
rightPanel.addWidget(stack2)
#rightPanel.addWidget(stack3)
def loadRightPanel(rightPanel):
stack1 =QWidget()
stack2 =QWidget()
#stack3 =QWidget()
stack1UI(stack1)
stack2UI(stack2)
#stack3UI()
rightPanel.addWidget(stack1)
rightPanel.addWidget(stack2)
#rightPanel.addWidget(stack3)
To copy to clipboard, switch view to plain text mode
and the UI for each stack looks like this:
def stack1UI(self,stack1):
welcomeText1
= QLabel("STACK1 - Android Forensic Automator (AnForA)", self
) welcomeText1.setAlignment(Qt.AlignCenter)
welcomeText1.
setFont(QtGui.
QFont("Times",
12, QtGui.
QFont.
Bold)) welcomeText2
= QLabel("a software tool that automates the forensic analysis of Android applications", self
) welcomeText2.
setFont(QtGui.
QFont("Times",
12)) layout1.addStretch(1)
layout1.addWidget(welcomeText1)
layout1.addWidget(welcomeText2)
layout1.addStretch(1)
stack1.setLayout(layout1)
def stack1UI(self,stack1):
layout1 = QVBoxLayout()
welcomeText1 = QLabel("STACK1 - Android Forensic Automator (AnForA)", self)
welcomeText1.setAlignment(Qt.AlignCenter)
welcomeText1.setFont(QtGui.QFont("Times", 12, QtGui.QFont.Bold))
welcomeText2 = QLabel("a software tool that automates the forensic analysis of Android applications", self)
welcomeText2.setFont(QtGui.QFont("Times", 12))
layout1.addStretch(1)
layout1.addWidget(welcomeText1)
layout1.addWidget(welcomeText2)
layout1.addStretch(1)
stack1.setLayout(layout1)
To copy to clipboard, switch view to plain text mode
but something is wrong and I'm little confuse.
Could you help me out, please?
M
Bookmarks