different items in one cell QTableWidget
<p>I am learning Qt and create a small example like this.</p>

<p><a href="http://i.stack.imgur.com/i4qsm.png" rel="nofollow">table</a></p>

<p>I have read some suggested questions which relate to my problem here but right now they are not easy for me to understand.</p>

<p>This is my code, above function is calendar interaction, below function is for showing items:</p>

<pre><code>SmallExample::SmallExample(QWidget *parent)
     : QWidget(parent)
{
    .........
    connect(ui.tableWidget, SIGNAL(itemDoubleClicked(QTableWidgetItem*)), this, SLOT(calendar_clicked(QTableWidgetItem*)));
}

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

    if (column == 2) {
        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 SmallExample::date_selected(const QDate&amp;)
{
    QTableWidgetItem *itemcalendar = new QTableWidgetItem;
    QIcon icon(":/icon/calendar.jpg");
    itemcalendar-&gt;setIcon(icon);
    SmallExample::ui.tableWidget-&gt;setItem(SmallExample::row, 0, itemcalendar);

    QString text= SmallExample::calendar-&gt;selectedDate().toString("dd.MM.yyyy");
    QTableWidgetItem *datetext = new QTableWidgetItem;
    datetext-&gt;setText(text);
    SmallExample::ui.tableWidget-&gt;setItem(SmallExample::row, 0, datetext);
    SmallExample::calendar-&gt;close();
}
</code></pre>

<p>I know when <code>datetext</code> is added, the <code>itemcalendar</code> will be overwritten, so it does not appear any more. I want both of which will appear, but I don't know how to solve this. Thanks in advance!</p>

<p>update code:</p>

<pre><code>void SmallExample::date_selected(const QDate&amp;)
{
    QTableWidgetItem *itemcalendar = SmallExample::ui.tableWidget-&gt;item(SmallExample::row, 2);
    QIcon icon(":/icon/calendar.jpg");
    itemcalendar-&gt;setIcon(icon);
    QString date = SmallExample::calendar-&gt;selectedDate().toString("dd.MM.yyyy")
    itemcalendar-&gt;setText(date);

}
</code></pre>