在計算abritary精確數字的程序中。 我在任務欄上有一個操作。在Qt上,如何在運行時更改工具欄中某個動作的圖標?
QAction* button_stop_continue.
我設置的圖標綠色圖標在節目的開始,正在執行計算時,應當開啓紅色等。
我已經嘗試過這樣的事情:
connect(this, SIGNAL(startedComputing()), this, SLOT(turnIconRed()));
connect(this, SIGNAL(finishedComputing()), this, SLOT(turnIconGreen()));
功能turnIconRed正在尋找類似這樣的:我來
void turnIconRed()
{
button_stop_continue->setIcon(QIcon("images/red-light.png"));
}
了一些令人難以置信的醜陋的算法:S。在Qt中處理這個問題不是直接的嗎?有任何想法嗎?
謝謝。
連接是無用的。相反,您可以根據需要調用任何方法。 – fasked
這只是爲了演示。代碼實際上完全不同。 –
我不明白問題是什麼:你發出一個信號,它發生了變化 - 它有多醜? – cmannett85