去除QTableWidget选中一行时单个Item的虚线框问题

一、解决方法

void MainWindow::InitTableWidget()
{
    //设置水平表头标题
    QStringList header;
    header<<"名称"<<"日期"<<"类型"<<"大小";
    ui->tableWidget->setColumnCount(4);
    ui->tableWidget->setHorizontalHeaderLabels(header);

    //设置表头各列的大小
    ui->tableWidget->horizontalHeader()->resizeSection(0,350);
    ui->tableWidget->horizontalHeader()->resizeSection(1,150);
    ui->tableWidget->horizontalHeader()->resizeSection(2,150);
    ui->tableWidget->horizontalHeader()->resizeSection(3,100);
    //设置最后列占满整个空间
    ui->tableWidget->horizontalHeader()->setStretchLastSection(true);

    //设置不显示子格线
    ui->tableWidget->setShowGrid(false);
    //设置垂直表头不可见
    ui->tableWidget->verticalHeader()->setVisible(false);
    //设置鼠标选择时选择一整行
    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
    //设置单行选中
    ui->tableWidget->setSelectionMode(QAbstractItemView::Single

你可能感兴趣的:(QT)