Trying to paint dates into QTableWidget for calendar dialog (Still need help)
Hi, I'm trying to write a very simple calendar program (I'm trying to learn Qt). The program itself is very basic, all it does is open a dialog box which displays today's date and then there is a button. When the button is pressed another dialog opens, which I'll call the calendar picker. The picker itself has a label for the month in the top and two buttons one for going to the last month and one for going to the next month. It also has a QTableWidget which is suppose to have the days of the week in it. I have managed to figure out how to work the buttons for switching months in the picker, however I don't know how to paint the dates onto the table itself.
It looks like this right now:
I'm not sure if the picture is going to show or not. If it doesn't here's a link to it "Link to Calendar Picture":http://i957.photobucket.com/albums/ae54/sindyhopps/Capture_zps3d751d24.jpghttp://i957.photobuc
This is what I know/ am trying to do. Sorry for the horrific code.
@void Picker::paintPicker(QDate my_date) //my_date is the current date
// I know I'm going to need some for loops here for the rows and columns. But I don't know how to write them.
// Also I think I might need my_date.daysInMonth() and my_date.addDays(1) to get through the loop with each date, but you guys probably know best.
QTableWidgetItem *item = new QTableWidgetItem(QString::number(my_date.day()));
ui->month_view->setItem(row, col, item);
Can anyone help me with this. I know where I want to go with this I just don't know how to implement it in Qt. Thank you!
Hi and welcome to devnet,
Are you thinking about the QCalendarWidget ?
Thank you for the welcoming. I'm trying to do something similar to the QCalendarWidget, but without using the widget class itself (if that makes any sense). I'm simply using QDate to make the calendar.
Never mind solved it myself.
Nice you found out, can you share your solution ?
And since you have it working now, can you update the thread title prepending [solved] so other forum users ma know a solution has been found :)