QCalendarWidget tooltip
Unsolved
General and Desktop
-
Hi,
From the looks of it, you will have to install an event filter to catch the
QEvent::ToolTip
event and react on that. -
@SGaist Can you help me with that? I read that I need to reimplement the QCalendarWidget class. I have this class:
#include "calendarmanager.h" CalendarManager::CalendarManager(QWidget *parent) : QCalendarWidget (parent) { // m_outlinePen.setColor(QColor(213,116,23)); m_outlinePen.setColor(Qt::transparent); m_transparentBrush.setColor(QColor(213,116,23,50)); getDates(); } CalendarManager::~CalendarManager() { } void CalendarManager::setColor(const QColor &color) { m_outlinePen.setColor(color); } QColor CalendarManager::getColor() const { return ( m_outlinePen.color() ); } void CalendarManager::paintCell(QPainter *painter, const QRect &rect, const QDate &date) const { QCalendarWidget::paintCell(painter, rect, date); if (m_dates.contains(date)) { painter->setPen(m_outlinePen); painter->setBrush(QBrush(QColor(213,116,23,50))); painter->drawRect(rect.adjusted(0, 0, -1, -1)); } } void CalendarManager::getDates() { // QFile file("C:\\Users\\Ivan\\Desktop\\prueba.txt"); // if (!file.open(QIODevice::ReadOnly)) { // // Error code // } // QList<QByteArray> wordList; // QDate date; // QString name; // calendarEvent e; // while (!file.atEnd()) { // QByteArray line = file.readLine(); // wordList = line.split(','); // date = QDate::fromString(wordList.first(), "dd/MM/yyyy"); // name = wordList.last(); // e.date = date; // e.name = name; // m_events.append(e); // m_dates.append(date); // } // file.close(); } void CalendarManager::setDateState(QDate dtDate, bool bState) { /* Esta es la funcionalidad mínima necesaria para pintar un día en el calendario */ calendarEvent e; e.date = dtDate; if (bState) { m_events.append(e); m_dates.append(dtDate); } else { for (int iDate = 0; iDate < m_events.size(); iDate++) { if (m_events.at(iDate).date == e.date) m_events.removeAt(iDate); if (m_dates.at(iDate) == e.date) m_dates.removeAt(iDate); } } }
How I have to proceed with the event filter? I think I read that I need it inside the paintCell function but I don't know how to do it.
Thank you very much!