Qt 中如何让独立的滚动条连接到选项卡式界面?这是我尝试过的,但是没有滚动条,而且一切都非常小。
import sys
from PyQt4 import QtGui
def main():
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.setWindowTitle('Scrolling Tabs Example')
tab1 = QtGui.QScrollArea()
tab1_layout = QtGui.QVBoxLayout(tab1)
text_browser_1 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_1)
text_browser_2 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_2)
text_browser_3 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_3)
text_browser_4 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_4)
text_browser_5 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_5)
text_browser_6 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_6)
text_browser_7 = QtGui.QTextBrowser()
tab1_layout.addWidget(text_browser_7)
tab2 = QtGui.QScrollArea()
tab2_layout = QtGui.QVBoxLayout(tab2)
button_1 = QtGui.QPushButton()
tab2_layout.addWidget(button_1)
button_2 = QtGui.QPushButton()
tab2_layout.addWidget(button_2)
button_3 = QtGui.QPushButton()
tab2_layout.addWidget(button_3)
tab_widget = QtGui.QTabWidget()
tab_widget.addTab(tab1, "Tab 1")
tab_widget.addTab(tab2, "Tab 2")
main_layout = QtGui.QVBoxLayout()
main_layout.addWidget(tab_widget)
main_layout.addStretch(1)
window.setLayout(main_layout)
window.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()