-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vertical scroll bar of panels is not proportional to the size of the content #21689
Comments
In the first image I used a test called MyTreeview. The vertical scrollbar works correctly sized for testing outside of Spyder. But when I add a vertical scrollbar to a Spyder panel it works strangely (small), a horizontal scrollbar works correctly. On the Spyder
Testing outside the Spyder
|
I used the test below and the vertical scrollbar works correctly. I'm checking the source of the problem. Do you know of anything that could direct a path?
|
Hey @dan123456-eng, thanks for reporting. Did you manage to solve this problem? Or did you close the issue by accident? If that was the case, then I think perhaps it occurs because the |
@ccordoba12 Sorry it was an accident. |
Ok, please change these lines in your code example above to be tree_view = QTreeView(parent=widget)
...
table_widget = QTableWidget(parent=widget) I think that should solve your problem. |
The vertical scroll bar for the correct code is correct, the code below is not. When used outside of Spyder it works correctly, when used in In the first image I used a test called MyTreeview. The vertical scrollbar works correctly sized for testing outside of Spyder. But when I add a vertical scrollbar to a Spyder panel it works strangely (small), a horizontal scrollbar works correctly. On the Spyder class PyMRWorkspacePluginWidget(PluginMainWidget):
"""PyMR workspace main widget."""
ENABLE_SPINNER = True
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
test = MyTreeView()
# Layout principal
lay = QtWidgets.QVBoxLayout(self)
lay.addWidget(test) Testing outside the Spyder from PyQt5 import QtWidgets, QtGui, QtCore
from spyder.api.widgets.main_widget import PluginMainWidget
class MyTreeView(PluginMainWidget):
def __init__(self, *args, **kwargs):
super().__init__('name', 'plugin')
model = QtGui.QStandardItemModel(self)
numofItems = 30
for x in range(numofItems):
item = QtGui.QStandardItem('Test {}'.format(x+1))
item.setCheckable(True)
item.setCheckState(QtCore.Qt.Checked) # Defina para QtCore.Qt.Unchecked se desejar desmarcar por padrão
model.appendRow(item)
treeView = QtWidgets.QTreeView(self)
treeView.setModel(model)
#treeView.setHeaderHidden(True) # Oculta o cabeçalho da QTreeView
v_scrollbar = treeView.verticalScrollBar()
v_scrollbar.setMinimumWidth(15) # Ajusta a largura da barra de rolagem conforme necessário
v_scrollbar.setStyleSheet("QScrollBar:vertical { width: 15px; }")
lay = QtWidgets.QVBoxLayout(self)
lay.addWidget(treeView)
self.setLayout(lay)
app = QtWidgets.QApplication([])
window = MyTreeView()
window.show()
app.exec_() |
I don't understand your code very well. Why does I think it doesn't need to inherit from |
In my code I use either Qtreeview or ProjectExplorerTreeWidget (which consists of ProjectExplorerTreeWidget - FilteredDirView- DirView- DirView(QTreeView, SpyderWidgetMixin)). Up to this point everything is correct. But when I implement my file tree in the PyMRWorkspacePluginWidge class inherited from PluginMainWidget the problem occurs. |
Hello @ccordoba12. We found out why the bug occurred. We were using custom styling in our plugins that caused this change in our implementation. Thank you for your help and as soon as I can I will contribute more. |
I'm glad you were able to find the cause of this problem and thanks for letting us know about it. |
Thank you for your attention. |
Problem Description
I noticed that in the Help panel and the IPython Console panel the vertical scrollbar works correctly (From what I understand it uses QWebEngineView).
Small vertical scrollbar
Correctly sized vertical scrollbar
What steps reproduce the problem?
Versions
Spyder version: 5.5.0
Python version: Python 3.12
Qt version: n/a
PyQt version: PyQt5= 5.15.10
Operating System name/version: Windows10 and Ubuntu
The text was updated successfully, but these errors were encountered: