ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.81k stars 729 forks source link

QTreeView size too small? #279

Closed ntjess closed 2 years ago

ntjess commented 3 years ago

Describe Your Environment

* OPERATING SYSTEM---------------------------------------------------------------
    - System........................ Linux
    - Release....................... 5.8.0-48-generic
    - Platform...................... Linux-5.8.0-48-generic-x86_64-with-glibc2.10
    - Version....................... #54-Ubuntu SMP Fri Mar 19 14:25:20 UTC 2021
* PYTHON DISTRIBUTION------------------------------------------------------------
    - Version....................... 3.8.5
    - C Compiler.................... GCC 7.3.0
    - C API Version................. 1013
    - Implementation................ cpython
    - Implementation Version........ 3.8.5
* QT BINDINGS--------------------------------------------------------------------
    - PyQt5 Version................. 5.15.4
    - PyQt5 Qt Version.............. 5.15.2
* QT ABSTRACTIONS----------------------------------------------------------------
    - qtpy Version.................. 1.9.0
    - qtpy Binding.................. pyqt5
    - qtpy Binding Variable......... os.environ['QT_API']
    - qtpy Import Name.............. qtpy
    - qtpy Status................... OK
    - pyqtgraph Version............. 0.12.1
    - pyqtgraph Binding............. Not set or inexistent
    - pyqtgraph Binding Variable.... os.environ['PYQTGRAPH_QT_LIB']
    - pyqtgraph Import Name......... pyqtgraph
    - pyqtgraph Status.............. OK
* PYTHON PACKAGES----------------------------------------------------------------
    - helpdev....................... 0.7.1
    - QDarkStyle.................... 2.8.1

[Versions from your environment]

Description / Steps to Reproduce [if necessary]

I have two QTreeViews next to each other in a VBoxLayout. In light mode (default), the spacing is appropriate since I have a customized size hint and minimum size. However, in dark mode, the top tree is 'squished'. It seems my size hint and minimum size are ignored.

https://user-images.githubusercontent.com/23620506/115135097-a768fc00-9fe3-11eb-97a6-945d8cecace8.mp4

Is this a problem with my code or qdarkstyle?

Code to reproduce

import qdarkstyle
from pyqtgraph.parametertree import ParameterTree, Parameter
from pyqtgraph.Qt import QtWidgets, QtCore
import pyqtgraph as pg

app = pg.mkQApp()
from utilitys.widgets import EasyWidget
# Populate both trees with some stuff
children = []
for ii in range(20):
  innerCh = [dict(name=str(jj), type='int', value=jj) for jj in range(4)]
  newCh = dict(name=f'nested{ii}', type='group', children=innerCh)
  children.append(newCh)
topParams = dict(name='test', type='group', children=children[:2])
botParams = dict(name='test2', type='group', children=children)

topTree = ParameterTree()
topTree.setParameters(Parameter.create(**topParams))
bottomTree = ParameterTree()
bottomTree.setParameters(Parameter.create(**botParams))

topTree.setSizePolicy(topTree.sizePolicy().horizontalPolicy(), QtWidgets.QSizePolicy.Fixed)
# Size is just a tad too small on its own regardless of darkstyle
oldSzHint = topTree.sizeHint
def newSzHint():
  baseHint = oldSzHint()
  baseHint.setHeight(int(baseHint.height()*1.1))
  return baseHint
topTree.setMinimumHeight(newSzHint().height())
topTree.sizeHint = newSzHint

# Make a window with a qslider between the two trees
win = EasyWidget.buildMainWin([topTree, bottomTree], useSplitter=True)
win.show()
QtCore.QTimer.singleShot(5000, lambda: win.setStyleSheet(qdarkstyle.load_stylesheet()))

app.exec_()

Note: It might be worth mentioning that for non-nested tree items, i.e. when all items are at the top level, this problem is not nearly as pronounced.

dpizetta commented 2 years ago

@ntjess thanks for reporting, could you reproduce with v3.0.X?

ntjess commented 2 years ago

Looks to be fixed in 3.0.3. Thanks!