gpt4 book ai didi

c++ - 如何从 QTableWidget::setCellWidget() 获取文本

转载 作者:太空宇宙 更新时间:2023-11-04 11:43:25 27 4
gpt4 key购买 nike

我正在尝试找出如何从 setCellWidget 获取 QLabel 文本。

我正在像这样设置我的 tableWidget:

    QLabel *nt = new QLabel();
nt->setStyleSheet("QLabel {padding-left:1px;color: white!important;display: block;float: left;border-radius: 11px;font-weight: bold!important;border: 2px solid #FFFFFF;box-shadow: 1px 1px 2px #999999;background: #d675a7;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f48282, stop: 1 #d00a0a);}");
nt->setText("1");
nt->setFixedWidth(22);
nt->setFixedHeight(22);
ui->tableWidget_3->setCellWidget(0,3,nt);

我正在尝试像这样检索值:

qDebug() << ui->tableWidget_3->item(0, 3)->text();

有什么想法吗?

最佳答案

ui->tableWidget_3->cellWidget(0, 3)->property("text").toString();

关于c++ - 如何从 QTableWidget::setCellWidget() 获取文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20565540/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com