如何在QT中使用QTable合并Header中的两列

时间:2017-05-05 09:26:43

标签: c++ qt qt4

如何使用QT合并标题中的两列。这个setSpan设置了列span,但不在标题中。 任何人都可以帮助我在标题中的列跨度。我给出了我的代码,并帮助我设置如何合并标题列。

-----------------------------------------------------------------
|      Date     |            Time           |    Description    |
|               |                           |                   |
-----------------------------------------------------------------
|  2000-05-10   |   05:00:00  |   10:35:00  | Information       |



    QTableWidget table = new QTableWidget();
    table->resize(600, 250);

    table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    table->setColumnCount(4);
    table->setRowCount(4);

     //Header Label
    table->verticalHeader ()->hide();
    table->horizontalHeader()->show();
    table->setFrameStyle(QFrame::NoFrame);
    table->setHorizontalHeaderLabels(QString("Date; Time; Description").split(";"));

    table->setItem(0, 0, new QTableWidgetItem("2000-05-10"));
    table->setItem(1, 0, new QTableWidgetItem("05:00:00"));
    table->setItem(2, 0, new QTableWidgetItem("10:35:00"));
    table->setItem(3, 0, new QTableWidgetItem("Information"));

    table->setSpan(0, 0, 1, 2);

0 个答案:

没有答案