How to Develop a Calendar Widget.
-
wrote on 7 Apr 2011, 09:28 last edited by
Thanks andre...
-
wrote on 8 Apr 2011, 05:32 last edited by
hello friends,still i dint get any concrete material so that i can develop a calendar for mobile..actually i want to use pushbuttons,for dates i.e very date is on pushbutton..so that i can click this button and i can add some notes for that button...but with the inbuilt widget its not possible i guess,because they have used QTableformat class and divided it into rows and columns..so friends please help me out..
regards
imrrk -
wrote on 8 Apr 2011, 06:48 last edited by
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.
-
wrote on 8 Apr 2011, 07:11 last edited by
but gerolf i just need the correct direction,have u seen the calendar of nokia phones..it has that feature...
-
wrote on 8 Apr 2011, 07:53 last edited by
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?
-
wrote on 8 Apr 2011, 07:55 last edited by
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.
-
wrote on 8 Apr 2011, 10:48 last edited by
hello gerolf,as u said,I need something should happen when i click on date..please guide me..
-
wrote on 8 Apr 2011, 11:07 last edited by
QCalendarWidget provides that already. See the signals listed in the documentation for that class.
-
wrote on 8 Apr 2011, 11:26 last edited by
[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.
-
wrote on 8 Apr 2011, 12:25 last edited by
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 -
wrote on 8 Apr 2011, 12:43 last edited by
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.
-
wrote on 8 Apr 2011, 13:04 last edited by
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,,,
-
wrote on 8 Apr 2011, 13:07 last edited by
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..
-
wrote on 8 Apr 2011, 13:12 last edited by
I was referring to how the dates and days of week are calculated not on how to do the actual drawing overall.
-
wrote on 8 Apr 2011, 13:22 last edited by
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..
-
wrote on 8 Apr 2011, 13:30 last edited by
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?
-
wrote on 8 Apr 2011, 13:38 last edited by
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. -
wrote on 8 Apr 2011, 17:48 last edited by
[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.
-
wrote on 12 Apr 2011, 05:27 last edited by
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....? -
wrote on 12 Apr 2011, 06:31 last edited by
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 }
}
@
24/119