Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Put a png image as cells backgrounds in a QCalendarWidget

Put a png image as cells backgrounds in a QCalendarWidget

Scheduled Pinned Locked Moved Solved General and Desktop
qcalendarwidget
9 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marquessbr
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @marquessbr

      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.

      http://www.qtcentre.org/threads/30478-How-To-Change-Style-Sheet-for-QCalendarWidget

      M 1 Reply Last reply
      2
      • mrjjM mrjj

        @marquessbr

        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.

        http://www.qtcentre.org/threads/30478-How-To-Change-Style-Sheet-for-QCalendarWidget

        M Offline
        M Offline
        marquessbr
        wrote on last edited by
        #3

        @mrjj

        Hi mrjj I got a calendar like I want using qml+javascript to get the images, it is working, but as Iam completely newbie in qt so, I stop it because I don't know how to connect this calendar with my cpp code, so what I need is to know how I can put this calendar:
        alt text
        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.

        jsulmJ 1 Reply Last reply
        0
        • M marquessbr

          @mrjj

          Hi mrjj I got a calendar like I want using qml+javascript to get the images, it is working, but as Iam completely newbie in qt so, I stop it because I don't know how to connect this calendar with my cpp code, so what I need is to know how I can put this calendar:
          alt text
          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.

          jsulmJ Online
          jsulmJ Online
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @marquessbr You can embed QML in widget using http://doc.qt.io/qt-5/qquickwidget.html

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          0
          • jsulmJ jsulm

            @marquessbr You can embed QML in widget using http://doc.qt.io/qt-5/qquickwidget.html

            M Offline
            M Offline
            marquessbr
            wrote on last edited by
            #5

            @jsulm

            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?

            thanks!

            jsulmJ 1 Reply Last reply
            0
            • M marquessbr

              @jsulm

              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?

              thanks!

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @marquessbr said in Put a png image as cells backgrounds in a QCalendarWidget:

              QQmlApplicationEngine

              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.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              M 2 Replies Last reply
              1
              • jsulmJ jsulm

                @marquessbr said in Put a png image as cells backgrounds in a QCalendarWidget:

                QQmlApplicationEngine

                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.

                M Offline
                M Offline
                marquessbr
                wrote on last edited by marquessbr
                #7

                @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?

                thanks!

                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.

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @marquessbr said in Put a png image as cells backgrounds in a QCalendarWidget:

                  QQmlApplicationEngine

                  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.

                  M Offline
                  M Offline
                  marquessbr
                  wrote on last edited by
                  #8

                  @jsulm

                  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.

                  thanks

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    marquessbr
                    wrote on last edited by
                    #9

                    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!

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved