Ejemplo n.º 1
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QMainWindow *w = new QMainWindow();

    w->setWindowTitle(QString::fromUtf8("QTableWidget Merge Cells Example"));
    w->resize(400, 250);

    QTableWidget* table = new QTableWidget();

    //Set table row count 1 and column count 3
    table->setRowCount(1);
    table->setColumnCount(3);
    table->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    //Set Header Label Texts Here
    table->setHorizontalHeaderLabels(QString("HEADER 1;HEADER 2;HEADER 3").split(";"));

    QTableWidgetItem* item = new QTableWidgetItem("ITEM 2");
    item->setTextAlignment(Qt::AlignCenter);

    //Add Table items here
    table->setItem(0,0,new QTableWidgetItem("ITEM 1"));
    table->setItem(0,1,item);
    table->setSpan(0,1,1,2);

    w->setCentralWidget(table);

    w->show();

    return a.exec();
}
Ejemplo n.º 2
0
int main( int argc, char* argv[] )
{
	QApplication app( argc, argv );
	QTableWidget* tv = new QTableWidget();
	tv->setRowCount( 1440 );
	tv->setColumnCount( 3 );
	tv->setShowGrid( false );

	QHeaderView* vh = tv->verticalHeader();
	vh->sectionResizeMode( QHeaderView::Fixed );
	vh->setDefaultSectionSize( 4 );

	QLabel* lbl = new QLabel( "abc" );
	tv->setCellWidget( 1, 1, lbl );

	tv->setSpan( 1, 1, 10, 1 );

	tv->show();
	app.exec();
}