Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to Develop a Calendar Widget.

How to Develop a Calendar Widget.

Scheduled Pinned Locked Moved Mobile and Embedded
119 Posts 11 Posters 82.3k 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.
  • G Offline
    G Offline
    giesbert
    wrote on last edited by
    #17

    If you have no existing code that works for you, start build it on your own. I have never seen a calendar build on buttons.

    We can give you ideas, suggestions for specific technical stuff. But we don't write your code. If you want it with buttons, sit down, take QtCreator and start coding.

    Nokia Certified Qt Specialist.
    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

    1 Reply Last reply
    0
    • I Offline
      I Offline
      imrrk
      wrote on last edited by
      #18

      but gerolf i just need the correct direction,have u seen the calendar of nokia phones..it has that feature...

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #19

        First: why do you think you need buttons? You can of course implement a calendar based on grid of buttons. I am just wondering how that would help you achieve your goals?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #20

          That you click on a button?
          Or that you click on a date and something happens?

          You can use a model/view (like Qt calendar widget) and react on the mouse events. No buttons needed. Qt has no build in "button calendar". and if you need one, build it. Or try if you can get the code for the nokia phone calendar.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • I Offline
            I Offline
            imrrk
            wrote on last edited by
            #21

            hello gerolf,as u said,I need something should happen when i click on date..please guide me..

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #22

              QCalendarWidget provides that already. See the signals listed in the documentation for that class.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #23

                [quote author="imrrk" date="1302259716"]hello gerolf,as u said,I need something should happen when i click on date..please guide me..[/quote]

                If you derive from, a view and can handle mouse events, clicks should be easy... (they are mouse events). Read a bit of Qt documentation on events (QWidget etc.) and views.

                Or look at QCalendarWidget and its interface. Perhaps derive from that.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • I Offline
                  I Offline
                  imrrk
                  wrote on last edited by
                  #24

                  ok thanks gerolf,hey i have created a two dimensional array of buttons,i.e 6 rows and 7 col,and by taking a counter i have my dates on pushbutttons,now the remaining work is to change the values on these buttons as the month and year changes..so any suggestions...

                  thanks
                  imrrk

                  1 Reply Last reply
                  0
                  • Z Offline
                    Z Offline
                    ZapB
                    wrote on last edited by
                    #25

                    Yes. As others have said many times already, take a look at how other calendar widgets are implemented. There is one right in Qt already. Use your favourite text editor/IDE/pager to look at the source code for QCalendarWidget and see how they solved the problem.

                    We are not here to write your code or do research for you. We are just a bunch of volunteers. We can help you out with specific technical problems but you have not shown what approaches you have tried to solve this problem yourself first.

                    Nokia Certified Qt Specialist
                    Interested in hearing about Qt related work

                    1 Reply Last reply
                    0
                    • I Offline
                      I Offline
                      imrrk
                      wrote on last edited by
                      #26

                      hi zapB,I have reffered to inbuilt example only and tried to do it in designer instead of hardcoding and wasting time,so what i have done has been mentioned already above,,,

                      1 Reply Last reply
                      0
                      • I Offline
                        I Offline
                        imrrk
                        wrote on last edited by
                        #27

                        hi gerolf,i am reading as per ur instructions,I have one doubt,we know that we have default calendar widget in qt designer which we can drag and drop on the form,whether your suggestion applies to this inbuit widget too..

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          ZapB
                          wrote on last edited by
                          #28

                          I was referring to how the dates and days of week are calculated not on how to do the actual drawing overall.

                          Nokia Certified Qt Specialist
                          Interested in hearing about Qt related work

                          1 Reply Last reply
                          0
                          • I Offline
                            I Offline
                            imrrk
                            wrote on last edited by
                            #29

                            i have reffered and know the logic,just want to do it in different way,hey can u tell me the default qcalendar widget in deesigner can be used in a efficient way..

                            1 Reply Last reply
                            0
                            • Z Offline
                              Z Offline
                              ZapB
                              wrote on last edited by
                              #30

                              What do you mean by "efficient way"? Just drop it on your form and hook up to it's signals. I am not clear exactly what you are trying to achieve. Do you have a graphic mockup of what you are after and a list of features?

                              Nokia Certified Qt Specialist
                              Interested in hearing about Qt related work

                              1 Reply Last reply
                              0
                              • G Offline
                                G Offline
                                giesbert
                                wrote on last edited by
                                #31

                                Hi imrrk,

                                as already told many times, and now last time:

                                make a derived class for what you described. Make a

                                @
                                class MyCalendarWidget : public QCalendarWidget
                                @

                                there change the mouse handling, change the drawing and you have what you need.
                                Then build up your UI on top of that.

                                Nokia Certified Qt Specialist.
                                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                                1 Reply Last reply
                                0
                                • G Offline
                                  G Offline
                                  goetz
                                  wrote on last edited by
                                  #32

                                  [quote author="imrrk" date="1302268936"]i have reffered and know the logic,just want to do it in different way,hey can u tell me the default qcalendar widget in deesigner can be used in a efficient way..[/quote]

                                  How should we know if it fits your needs? What a strange question...

                                  How about just getting your hands dirty and trying it? In the time you wrote all this comments you could have ended up with a prototype showcase.

                                  http://www.catb.org/~esr/faqs/smart-questions.html

                                  1 Reply Last reply
                                  0
                                  • I Offline
                                    I Offline
                                    imrrk
                                    wrote on last edited by
                                    #33

                                    Hello friends,
                                    I have taken an taken an inbuilt QCalendarwidget and written a slot ,here when i click on dates i get the same date on the textbrowser.below is my code.
                                    dialog.cpp

                                    @#include "dialog.h"
                                    #include "ui_dialog.h"
                                    #include<QCalendarWidget>
                                    #include<QDate>

                                    Dialog::Dialog(QWidget *parent) :
                                    QDialog(parent),
                                    ui(new Ui::Dialog)
                                    {
                                    ui->setupUi(this);
                                    QCalendarWidget *cal=new QCalendarWidget();
                                    cal->setDateEditEnabled(1);
                                    cal->setFirstDayOfWeek(Qt::Wednesday);

                                    cal->show();
                                    }

                                    Dialog::~Dialog()
                                    {
                                    delete ui;
                                    }

                                    void Dialog::on_calendarWidget_clicked(QDate date)
                                    {
                                    ui->textBrowser->setText(date.toString());

                                    }

                                    @
                                    i know its simple,but i want to know whether in a similar way,we can open a new dialog on clicking a date....?

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      andre
                                      wrote on last edited by
                                      #34

                                      Sure. In your on_calendarWidget_clicked(QDate date), you do something like this:

                                      @
                                      void Dialog::on_calendarWidget_clicked(QDate date)
                                      {
                                      MyFancyDialog dlg(this); // MyFancyDialog is derived from QDialog
                                      dlg.setDateToWorkWith(date); // I guess the dialog needs to do something with the date
                                      if (dlg.exec() == QDialog::Accepted) { // this will make the dialog modal

                                          //now do something with the results
                                          //you can give MyFancyDialog member functions to access the resulting data
                                      }
                                      

                                      }
                                      @

                                      1 Reply Last reply
                                      0
                                      • I Offline
                                        I Offline
                                        imrrk
                                        wrote on last edited by
                                        #35

                                        hi andre,
                                        i opened a new dialog with the below code:
                                        @void Dialog::on_calendarWidget_clicked(QDate date)
                                        {
                                        Dialog1 a(this);
                                        a.show();
                                        a.exec();
                                        }@
                                        hey
                                        dlg.setDateToWorkWith(Date).whether its in built function?,because i didnt find it..

                                        and one more thing ,i want to know can we change the color of cells ?

                                        1 Reply Last reply
                                        0
                                        • Z Offline
                                          Z Offline
                                          ZapB
                                          wrote on last edited by
                                          #36

                                          You have to write your own custom dialog that inherits QDialog. How on earth is Qt supposed to ship a dialog already tailored to your precise needs? Andre just made that function name up as an example.

                                          Nokia Certified Qt Specialist
                                          Interested in hearing about Qt related work

                                          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