View Single Post
Posts: 47 | Thanked: 41 times | Joined on Jan 2010 @ Finland
#5
Originally Posted by fpp View Post
Well, individual tabs are just QWidgets, and any QWidget has a setVisible() method, so I'd have thought you could hide/show them independently. But admittedly I haven't tried :-)
Not working, only way to "hide" the tabs (at least in 4.6) is to use remove and add -functions. Which is stupid because if the tabs has indexes anyway, it shouldn't be so hard to write up the method for it, something like QTabWidget::hideTab(int index) and QTabWidget::showTab(int index), I wish I could do that by myself, but I don't know how (not enough skills).

Anyway the problem is kind of solved. (Should I put [SOLVED] in the topic of first message?)

I couldn't figure out how to add and remove tabs from different class, so I modified the code so that all parts of GUI (mainwin, tabs, widgets in tabs and dialogs) and UI handling codes are now on in same class (Class MainWindow) and now it is possible to manage the gui after it is shown.

Now the code I posted previously looks like this (just in case someone want to know):

Code:
class MainWindow(QtGui.QMainWindow):
    def __init__(self):
        # ...
        # Creating tabs and using tab widget as a Central widget
        
        self.tabs = QtGui.QTabWidget()
        self.tabs.TabShape(QtGui.QTabWidget.Rounded)
        self.tabs.addTab(self.basicMode(), "Basic") # index = 0
        self.tabs.addTab(self.bulbMode(), "Bulb") # index = 1
        self.tabs.addTab(self.timedMode(), "Timed") # index = 2
        self.tabs.addTab(self.viewerMode(), "Viewer") # index = 3
        self.tabs.addTab(self.systemMode(), "System") # index = 4
        
        self.setCentralWidget(self.tabs)
        #...
        self.tabVisibility()
        #...
 
    def tabVisibility(self):
        count = self.tabs.count() # Number of tabs, used for failsafe!
        if USEFULLSCREEN != True and count == 5: # Removing systemMode if not fullscreen
            self.tabs.removeTab(count-1)
        
        if CURRENT_REMOTETYPE == "Olympus_RM-1" and USEFULLSCREEN == True and count < 5: # Includes Viewer tab, only if it is not there!
            self.tabs.removeTab((count-1))
            self.tabs.addTab(self.viewerMode(), "Viewer")
            self.tabs.addTab(self.systemMode(), "System")
        
        elif CURRENT_REMOTETYPE == "Olympus_RM-1" and USEFULLSCREEN != True and count == 3: # Includes Viewer tab, only if it is not there!
            self.tabs.addTab(self.viewerMode(), "Viewer")
        
        elif CURRENT_REMOTETYPE != "Olympus_RM-1" and count == 5:
            self.tabs.removeTab(3)
    
    def settingsDialog(self):
        #...
        
    def setSettings(self):
        #...
        self.tabVisibility() # Handling visibility of tabs
        settings.sync()
        self.dialog.accept()
 

The Following User Says Thank You to Yabba For This Useful Post: