簡體   English   中英

Qt Creator C ++,設置Statuslabel的文本

[英]Qt creator C++, setting text of Statuslabel

m_pointLabel->setText(tr("Vertices: " .  m_drawingWidget->getPointListSize()));
m_pointLabel->setText(tr("Vertices: " . m_drawingWidget->getLineListSize()));'

我正在嘗試設置文本,但是出現以下錯誤。

request for member 'm_drawingWidget' in "Vertices: ", which is of non-class type 'const char [11]'

getPointListSize()getLineListSize()返回INT值,那么該如何設置此文本?

. 是PHP中的串聯運算符,但C ++ / Qt 不是 PHP。

采用:

tr("Vertices: %1").arg(m_drawingWidget->getPointListSize())

您正在將字符串文字視為類。 這就是為什么它會給出錯誤。

解決方法是:

m_pointLabel->setText(tr("Vertices: %1").arg(m_drawingWidget->getPointListSize()));
                                     //^^^^^^ Note this!

對其他setText也執行完全相同的操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM