Answer the question
In order to leave comments, you need to log in
PyQt5. QTabWidget. How to customize a separate tab?
I make tabs with text in the manner of chrom. I want a special tab, when I change to which, I will create new tabs. It cannot be closed, it is always on the right. Now I'm struggling with the question of deleting the close button from this (only from it) tab. Tried to use tabBar() but if I understood correctly it is for pyqt4. Or not. Help I'm stuck
class Tabs(QTabWidget):
quantity = 10
tabs = [["File" + str(i), None] for i in range(1, quantity)]
def __init__(self):
super().__init__()
self.new_button = QFrame()
self.addTab(self.new_button, "NEW")
self.new_tab()
self.new_tab()
self.setTabsClosable(True)
self.setMovable(True)
#self.tabBar().setTabButton(0, self.currentIndex(0).RightSide, None)
self.tabCloseRequested.connect(self.delete_tab)
self.currentChanged.connect(self.change_new_tab)
...
Answer the question
In order to leave comments, you need to log in
I changed the commented line to
self.tabBar().setTabButton(0, self.tabBar().RightSide, None)
You need to make two classes: one describes a regular tab (one, the class itself describes one tab), and the second is an opening one.
And then add instances of these classes to the parent widget
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question