user3082584
user3082584

Reputation: 167

How to get the text from QTableWidget::setCellWidget()

I'm trying to figure out how to get the QLabel text from setCellWidget.

I'm setting my tableWidget up like this:

    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);

And I am trying to retrieve the value like so:

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

Any ideas whats wrong?

Upvotes: 1

Views: 963

Answers (1)

L&#225;szl&#243; Papp
L&#225;szl&#243; Papp

Reputation: 53155

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

Upvotes: 1

Related Questions