水平滚动条没有出现在我的QTableWidget中

时间:2019-06-17 05:37:03

标签: python pyqt

我正在尝试使用PyQt5创建一个显示公交路线中每个站点的到达时间的表格,但是,即使我拥有的列数大于窗口小部件的大小,我的水平滚动条也不会出现。当我使用表格小部件自动滚动功能时,可以在表格中看到其他值,但无法使用滚动条

我已经尝试将水平滚动条策略设置为始终使用此显示:

self.route_search_table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)

但这似乎不起作用

即使我的垂直滚动条也出现了,因为垂直停止的数量大于桌子的高度。


# Route search table display settings
self.route_search_table = QtWidgets.QTableWidget(self.route_search_frame)
self.route_search_table.setGeometry(QtCore.QRect(20, 180, 371, 251))
self.route_search_table.setStyleSheet("background-color: rgb(255, 255, 255)")
self.route_search_table.setObjectName("route_search_table")
self.route_search_table.setColumnCount(0)
self.route_search_table.setRowCount(0)

# Setting up the vertical and horizontal scroll bar for the route search table
self.route_search_table.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
self.route_search_table.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.route_search_table.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)    
self.route_search_table.setHorizontalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)

为什么没有显示水平滚动条?

0 个答案:

没有答案