qt 创建表格

g++ hello2.cpp -I/opt/bin/qt570/5.7/gcc_64/include -o hello.o -fPIC -L /opt/bin/qt570/5.7/gcc_64/lib/ -lQt5Core -lQt5Widgets -lQt5Gui

#include <QtWidgets/QApplication>
//#include <QtCore>
//#include <QtGui/QApplication>
#include <QtWidgets/QTableWidget>
#include <QtWidgets/QTableWidgetItem>
#include <QtWidgets/QLabel>

int main(int args,char** argv)

{

    QApplication app(args,argv);

    QLabel *hello=new QLabel("<font color-red>Hello <i>World!</i>""</font>",0);

    hello->show();

    return app.exec();

}

/*
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTableWidget *tableWidget = new QTableWidget(10,5); // 构造了一个QTableWidget的对象,并且设置为10行,5列
    //    也可用下面的方法构造QTableWidget对象
    //    QTableWidget *tableWidget = new QTableWidget;
    //    tableWidget->setRowCount(10);     //设置行数为10
    //    tableWidget->setColumnCount(5);   //设置列数为5
    tableWidget->setWindowTitle("QTableWidget & Item");
    tableWidget->resize(350, 200);  //设置表格
    QStringList header;
    header<<"Month"<<"Description";
    tableWidget->setHorizontalHeaderLabels(header);
    tableWidget->setItem(0,0,new QTableWidgetItem("Jan"));
    tableWidget->setItem(1,0,new QTableWidgetItem("Feb"));
    tableWidget->setItem(2,0,new QTableWidgetItem("Mar"));
 
    tableWidget->setItem(0,1,new QTableWidgetItem(QIcon("images/IED.png"), "Jan's month"));
    tableWidget->setItem(1,1,new QTableWidgetItem(QIcon("images/IED.png"), "Feb's month"));
    tableWidget->setItem(2,1,new QTableWidgetItem(QIcon("images/IED.png"), "Mar's month"));
    tableWidget->show();
 
    return a.exec();
}
*/

转载于:https://my.oschina.net/innovation/blog/3048245

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值