Disable choosing date in the future in QCalendarWidget
<p>This is the standard calendar</p>

<p><a href="https://i.stack.imgur.com/fNiyc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fNiyc.png" alt="calendar"></a></p>

<p>I want to make <strong>the dates from tomorrow in this calendar appear in grey</strong>, and <strong>we can not select the date from tomorrow on</strong>, we can only select date from the past until today. Is that possible?</p>

<p>This is my code:</p>

<pre><code>MyClass::MyClass(QcgDatabase * db, int hostid, QWidget *parent)
: QWidget(parent)
{
    ui.setupUi(this);
    connect(ui.tableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(calendar_clicked(QTableWidgetItem*)));
}

void MyClass::calendar_clicked(QTableWidgetItem* tableitem) 
{
    int column = tableitem-&gt;column();
    clicked_item = tableitem;

    if (!calendar) {
        calendar = new QCalendarWidget();
    }
    calendar-&gt;setWindowTitle("Calendar");
    calendar-&gt;setWindowModality(Qt::WindowModal);
    calendar-&gt;show();
    connect(calendar, SIGNAL(activated(const QDate&amp;)), this, SLOT(date_selected(const QDate&amp;)));
}

void MyClass::date_selected(const QDate&amp;)
{
    if (!clicked_item) {
        return;
    }
    QIcon icon(":/myclass/icon/calendar.png");
    clicked_item-&gt;setIcon(icon);
    clicked_item-&gt;setText(calendar-&gt;selectedDate().toString("dd.MM.yyyy"));
    calendar-&gt;close();
}
</code></pre>