How to Develop a Calendar Widget.
-
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.
-
[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.
-
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 -
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.
-
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. -
[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.
-
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....? -
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 }
}
@ -
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 ?
-
[quote author="imrrk" date="1302591858"]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..[/quote]
Eh, what do you think? I make up an obviously fake dialog name with an obviously fake method name, and you expect that to be in Qt by default. And what should that method do then, exactly? Also: there is no need to call both show() and exec(). Either one will suffice.
[quote]
and one more thing ,i want to know can we change the color of cells ?[/quote]
You mean of your calendar widget, right? Perhaps you could read the documentation of the QCalendarWidget? I just did, and found what you need in less than ten seconds.