Open oleschum opened 2 years ago
I've seen this issue too. Using a regular calendar widget works fine, but the popup in a QDateEdit is cut off slightly at the bottom.
hey @josys36 @oleschum ,
You can use a custom CSS to temporary fix this issue:
from PyQt5 import QtWidgets, QtCore
import qt_material
import sys, os
class DateEditGui(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
widget = QtWidgets.QWidget()
self.vertical_layout = QtWidgets.QVBoxLayout()
self.date_picker = QtWidgets.QDateEdit()
self.date_picker.setDate(QtCore.QDate.currentDate())
self.date_picker.setMinimumDate(QtCore.QDate.currentDate())
self.date_picker.setCalendarPopup(True)
self.vertical_layout.addWidget(self.date_picker)
widget.setLayout(self.vertical_layout)
self.setCentralWidget(widget)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
qt_material.apply_stylesheet(app, theme="dark_teal.xml")
# load custom CSS
stylesheet = app.styleSheet()
with open('/tmp/custom.css') as file:
app.setStyleSheet(stylesheet + file.read().format(**os.environ))
####################################################
window = DateEditGui()
window.show()
app.exec_()
Create /tmp/custom.css with this content:
/* QCalendarWidget */
QCalendarWidget QAbstractItemView {{
padding: 3px;
margin: 3px;
}}
It's actually easier to add,
QCalendarWidget QAbstractItemView { padding: 3px; margin: 3px; }
to material.css.template
That works too.
you're right. The only problem is that it's not portable across computers. You should have to overwrite the file shipped with qt-material, which would be overwritten if the package is updated and does not include that change.
But anyway, that's the actually fix. Submit a PR! :)
That is very true. Your method works well. Can one also use this method to adjust the font size for individual widgets? Like let's say I want a QLineEdit and QLabel to be a larger font, but I leave the font the default size on a QPushButton. If I adjust the font size globally the QPushButtons look too big. I tried using the Extras method provided, but the font size appears to go back to a default if you apply a style sheet to an individual widget.
Honestly I think the best way to customize this is to just export the theme you are working with, and then make your changes there. I exported the dark amber theme and adjusted the calendar widget, and also made changes to QPushButton.
I agree @josys36 . It'd be nice to have this little bug fixed btw
Hi, what do you think about setting a fixed minimum size?
QCalendarWidget {
min-height: 300px;
}
tested with latest v2.14 and this issue seems to be solved, @josys36 @oleschum , could you test it with latest release?
When using a QDateEdit widget with popup (which is a QCalendarWidget), then the lower part of the popup is cut off, see image:
Additionally, colors for days of the next month are not different from colors used for the days in the current month. The same holds true for days that are not available for selection (MinimumDate).
I work with Ubuntu 22.04, Pyside2 (same holds true for Pyside6), Python 3.10.
MWE to reproduce this: