QT设置table居中

setTableAligCenter(QTableWidget *tw)
{
    int rowCount = tw->rowCount();
    int columCount = tw->columnCount();
    for(int row=0;row<rowCount;row++)
    {
        for(int colum=0;colum<columCount;colum++)
        {
            QTableWidgetItem* item = tw->item(row, colum);
            if(item != nullptr)
            {
                item->setTextAlignment(Qt::AlignCenter);
            }
        }
    }
}
posted @ 2021-12-23 15:40  Azuki_op  阅读(628)  评论(0)    收藏  举报