For such a toggle state property I would actually recommend going with a bool as the value type 
Or with an int and a pre-filled array for the strings, something like
QVector<QString> m_pumpTexts;
QVector<QString> m_pumpTexts;
To copy to clipboard, switch view to plain text mode
m_pumpTexts << tr("Pump Off") << tr("Pump On");
m_pumpTexts << tr("Pump Off") << tr("Pump On");
To copy to clipboard, switch view to plain text mode
void MainWindow
::pumpLabelOnOff(QLabel *pl
) {
const int nextState = (pl->property("pumpState").toInt() + 1) % 2;
pl->setText(m_pumpTexts[nextState]);
pl->setProperty("pumpState", nextState);
}
void MainWindow::pumpLabelOnOff(QLabel *pl)
{
const int nextState = (pl->property("pumpState").toInt() + 1) % 2;
pl->setText(m_pumpTexts[nextState]);
pl->setProperty("pumpState", nextState);
}
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks