QYolk II - Containers
How to use a Tab Widget
In this tutorial we will use one of Containers widgets - Tab Widget. In the first part of the QYolk tutorial we ended up with a GUI like this:





Singals and Slots with parameters
QTabWidget has a signal currentChanged which will be send when you change a tab. Note the documentation:void currentChanged (int)
This signal has a parameter (integer). Until now we used signals with no parameters. In this case the "int" will be ID of the selected tab counting from 0. We connect the signal with a slot the usual way, but we add the parameters in ():
QtCore.QObject.connect(self.ui.pkgTabs,QtCore.SIGNAL("currentChanged(int)"), self.tab_change)
tab_id is a argument (our name), which will store the selected widget ID number. First signal parameter is mapped to the first argument of the slot and so on. We can use this signal to change the label text based on the tab which have been selected":
I used the self.ui.infoLabel.setText to change the label text. Our QYolk application has more features and in next tutorials we will add even more.Download
Download Sources
RkBlog