Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Put a png image as cells backgrounds in a QCalendarWidget
I Need to put a different image as background for each monthly day in a QCalendarWidget, these images are in a resources.qrc file and are named as img_000.png to img_030.png and will be changed according the respective month and day, this mechanism for get the images is ok and working, but I don't know how to change the cell background of a QCalendarWidget.
At this moment I have done the calendar and changed it to attend my necessity, but I need to put these image as background.
Someone can help-me?
Thanks in advance!
Hi did you subclass QCalendarWidget ?
As far as i know, you can change whole background with stylesheet
So when change month yo umight be able to change stylesheet and get image
but i never tested this.
made using qml into my QCalendarWidget constructor in my cpp file, and then connect its my own navbar to correspond to the calendarwidget navbar, e.g.: the minus and plus button increment and decrement month, the "<" and ">" increment and decrement day and toggle the minus button pressed, appear a menu with more date options, and the textEdit or label show the new selected date as "mm/dd/yyyy" format.
It is all for now.
Hi, jsulm, in the qt examples set I see "QGuiApplication" and "QQmlApplicationEngine", these are the same or your effects is equal or similar of QQuickWidget?
If I understand you correctly you want to write a widget application but embed this QML calendar, right? If so then QGuiApplication is what you need.
marquessbr last edited by marquessbr
@jsulm Yes its just it, it is very complicated for me: java programmer, so I will try here and when I conclude I mark the post solved, it's ok?
PS.: @jsulm, im as I said, I start creating it using qml, but when I try to connect the buttons to they respective actions, I got difficult, so I try to implement it using widget, but later, I see which is possible to embed qml into c++ code.
Hi my friend!
I got it working here, at last I can made the buttons of my custom navigation bar working, but now I need to know how I can made the calendar to reflect the changes of the buttons, so I have the qml code: https://pastebin.com/GcT6S47B
As I got this working, maybe I can solve this thread and post a new Question, as I say Iam newbie in qt and in this forum also.
Now it is working here, I connect the buttons action to the calendar using:
currentDate.setFullYear(aNewYear, aNewMonth, aNewDay); calendar.selectedDate = new Date(aNewYear, aNewMonth, aNewDay); calendar.update();
Now I have a calendar and a custom navigation bar
thanks for all!