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 6 Jul 2017, 13:36 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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 6 Jul 2017, 13:41 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 6 Jul 2017, 22:35
      2
      • M mrjj
        6 Jul 2017, 13:41

        @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 6 Jul 2017, 22:35 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.

        J 1 Reply Last reply 7 Jul 2017, 04:26
        0
        • M marquessbr
          6 Jul 2017, 22:35

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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 7 Jul 2017, 04:26 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 7 Jul 2017, 05:51
          0
          • J jsulm
            7 Jul 2017, 04:26

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

            M Offline
            M Offline
            marquessbr
            wrote on 7 Jul 2017, 05:51 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!

            J 1 Reply Last reply 7 Jul 2017, 05:54
            0
            • M marquessbr
              7 Jul 2017, 05:51

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 7 Jul 2017, 05:54 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 7 Jul 2017, 06:01
              1
              • J jsulm
                7 Jul 2017, 05:54

                @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 7 Jul 2017, 06:01 last edited by marquessbr 7 Jul 2017, 06:06
                #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
                • J jsulm
                  7 Jul 2017, 05:54

                  @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 9 Jul 2017, 16:05 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 9 Jul 2017, 22:13 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

                    3/9

                    6 Jul 2017, 22:35

                    6 unread
                    • Login

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