How to Develop a Calendar Widget.
-
wrote on 19 Apr 2011, 07:19 last edited by
ok thanks andre,i got it
-
wrote on 19 Apr 2011, 08:38 last edited by
Hello andre
As i am very new to qt so can u give me a brief idea of hw to implement paintCell to do the rendering of each cell...
with regards
Anshuman -
wrote on 19 Apr 2011, 08:50 last edited by
Why don't you use the QCalendarWidget sources as inspiration for that?
-
wrote on 19 Apr 2011, 09:22 last edited by
hello andre
thanks for ur reply..
Actually i hv been go through that source code..but i havent found any idea regarding setting of background image in particular cell..and as u said that to set an image in a particular cell we hv to implement paintcell to do the rendering of each cell…but hw this can be done..can u give me an idea for that
with regards
Anshuman -
wrote on 19 Apr 2011, 09:59 last edited by
The signature of the method is:
@
QCalendarWidget::paintCell(QPainter *painter, const QRect &rect, const QDate &date)
@So, I suggest you have a look at QPainter's drawImage(), drawPixmap() and drawPicture() methods.
-
wrote on 19 Apr 2011, 10:00 last edited by
You know what? Perhaps you should look into this yourself. Did you look in the documentation for QPainter?
-
wrote on 19 Apr 2011, 10:06 last edited by
hey volker through paintcell method can we add image to the particular cells in calendarwidget?.in my project i have directly taken the qcalendarwidget and dragged it in the form,so how i should implement it.
regards
imrrk -
wrote on 19 Apr 2011, 10:11 last edited by
[quote author="imrrk" date="1303207582"]hey volker through paintcell method can we add image to the particular cells in calendarwidget..
[/quote]You know the meaning of the sign "?", don't you? If so, then please use it appropriately, if not, please look up in google.
And now, please read the documentation on QPainter. We will not do this for you, this is your part! It has all the information you need and to start playing around.
-
wrote on 19 Apr 2011, 10:12 last edited by
Please just try it. Andre and Volker are not your personal assistants. They have even told you which QPainter calls to read up on. The clue is in the name QPainter::drawPixmap()!
-
wrote on 19 Apr 2011, 10:16 last edited by
i know volker,fine,i will read the doc and get back to you with my code..
regards
imrrk -
wrote on 19 Apr 2011, 10:16 last edited by
hello volker
actually i had read about QPainters but doesnt know hw to implement it..from where to start
i had given a code,,u plz check it whether its ok to work or not..
@QPainter* pPainter = new QPainter(this);
pPainter->drawPixmap(rect(), QPixmap(":/images/bg.png"));@after that what should i do cant find it
regardsAnshuman
-
wrote on 19 Apr 2011, 10:37 last edited by
Read the docs. If you really do so, you will find a link to an example that even contains drawing pixmaps. Grab it, play with it, adapt it. This all is really basic stuff, explained multiple times in the docs with uncountable examples in the docs. We're not going to do your homework!
-
wrote on 19 Apr 2011, 10:40 last edited by
imrrk and/or Anshuman:
I am really done with this thread. Please do all of us here, including first and foremost yourself, a big favor, and get yourself enrolled in a good programming course in C++. If they use Qt, than that is a bonus, but that is not even needed. Otherwise, perhaps you should draft up a document describing what you want to achieve (not how you want to do that), and get yourself a consultant to do the work for you. I think a good one can do what you have achieved in the course of weeks of postings and copy/pasting snippets you have managed to beg of the contributers here in a matter of an hour or so. As it stands, I doubt you are able to ever complete whatever project you are on, and I feel spending any more time on this issue is a waste.
All the best of luck, I am signing off.
-
wrote on 19 Apr 2011, 10:58 last edited by
ok..volker and /andre..thanks..i will try my level b est in doing so..but if any doubt arises i will ask u..
with regards
Anshuman -
wrote on 19 Apr 2011, 11:28 last edited by
[quote author="BorahAnshuman" date="1303210680"]ok..volker and /andre..thanks..i will try my level b est in doing so..but if any doubt arises i will ask u..
with regards
Anshuman[/quote]You (in plural or singular meaning - choose whatever you want) may ask, but don't expect any further answers. I step out too.
-
wrote on 20 Apr 2011, 10:08 last edited by
Hello Volker
as per ur suggestion i hv read QPainter class in QT..as per ur discussion i hv tried this code in setting backgroundImage in a particular cell in CalenderWidget but an error occur..cn u please check the error..
@void PainterApp::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QRectF target(30.0, 40.0, 80.0, 60.0);
QRectF source(30.0, 40.0, 70.0, 40.0);
QImage image("C:/QTWork/back-icon.png");painter.drawImage(target, image, source); ui->calendarWidget->paintCell(painter,target,QDate::currentDate()); painter.end();
}@
regards
Anshuman -
wrote on 20 Apr 2011, 11:46 last edited by
Why u using a paint event handler to do the painting?
And if you ask to check the error, then why i dont see any output?
Pleae post your error, or even better make a small app in wich your problem occurs and post it.Edit:
On a site where trolls are super admin, it doesnt mean that you must "troll" yourself. -
wrote on 20 Apr 2011, 11:55 last edited by
What are you doing? To get custom painting do this:
Derive a class from QCalendarWidget
Reimplement the paintCell() protected virtual function to do you custom painting
Use your custom class in your app instead of QCalendarWidget
When you reimplement the paintCell() function I suggest you make the changes from the base class version very incrementally so that you can see what the changes do and learn as you go along.
-
wrote on 20 Apr 2011, 12:04 last edited by
[quote author="BorahAnshuman" date="1303294092"]Hello Volker
as per ur suggestion i hv read QPainter class in QT..as per ur discussion i hv tried this code in setting backgroundImage in a particular cell in CalenderWidget but an error occur..cn u please check the error..
regards
Anshuman[/quote]What was so unclear about my last statement?
[quote author="Volker" date="1303212502"]
You (in plural or singular meaning - choose whatever you want) may ask, but don't expect any further answers. I step out too.[/quote]Are you trying to troll me?
-
wrote on 20 Apr 2011, 12:19 last edited by
hello ZapB
Actually i inherit Qdialog and QCalenderWidget class..now when i build my app the following error ocurrs...can anyone suggest me why is occur..
Error r....
Rquest for member show() is ambiguous //show in main .cpp
the code i hv wrritten is:
@class PainterApp : public QDialog,public QCalendarWidget
{
Q_OBJECTpublic:
explicit PainterApp(QWidget *parent = 0);
~PainterApp();private:
Ui::PainterApp *ui;
};
@
@void PainterApp::paintCell(QPainter * painter, const QRect & rect, const QDate & date ) const{QRectF target(30.0, 40.0, 80.0, 60.0); QRectF source(30.0, 40.0, 70.0, 40.0); QImage image("C:/QTWork/back-icon.png"); painter->drawImage(target, image, source); ui->calendarWidget->paintCell(painter,rect,date.currentDate());
}@
with reagrds
Anshuman
99/119