HappyCoder
31st August 2015, 15:16
Hi,
i have in one of my form class a QButtonBox and i wand to change the text from "OK" to "Export" (translatable).
1) The easy way is to search for the QString "OK", but if i activate other languages it is not "OK" anymore.
2) An other easy way is to use a fixed indexOfOk, "try and error method" till i have the right index to OK Button, but it is not very flexible
I use this so far:
// change "OK" to "Export"
QList<QAbstractButton *> buttonList = ui->buttonBox->buttons();
int indexOfOk = -1;
for( int i=0; i<buttonList.size(); i++ )
{
if ( ? ) // how must my if looks like
{
indexOfOk = i;
break;
}
}
if( indexOfOk != -1 )
ui->buttonBox->buttons().at( indexOfOk )->setText(QString("Export"));
QButtonBox::buttons() gives me a QList<QAbstractButtons *>.
I can't find any relation between QAbstractButton and QDialogButtonBox::Ok ( Widget vs. enum )?
Thx
i have in one of my form class a QButtonBox and i wand to change the text from "OK" to "Export" (translatable).
1) The easy way is to search for the QString "OK", but if i activate other languages it is not "OK" anymore.
2) An other easy way is to use a fixed indexOfOk, "try and error method" till i have the right index to OK Button, but it is not very flexible
I use this so far:
// change "OK" to "Export"
QList<QAbstractButton *> buttonList = ui->buttonBox->buttons();
int indexOfOk = -1;
for( int i=0; i<buttonList.size(); i++ )
{
if ( ? ) // how must my if looks like
{
indexOfOk = i;
break;
}
}
if( indexOfOk != -1 )
ui->buttonBox->buttons().at( indexOfOk )->setText(QString("Export"));
QButtonBox::buttons() gives me a QList<QAbstractButtons *>.
I can't find any relation between QAbstractButton and QDialogButtonBox::Ok ( Widget vs. enum )?
Thx