Attempting to change QImage text
Solved
QML and Qt Quick
-
I have a
QImage
which I am painting in the constructor like so:QImage image(prjcfgISO11783UT_datamaskWidth+2, prjcfgISO11783UT_datamaskHeight+2, QImage::Format_Mono); image.fill(1); QPainter painter; painter.begin(&image); painter.setPen(Qt::black); painter.drawText(QRect(0, 0, prjcfgISO11783UT_datamaskWidth+2, prjcfgISO11783UT_datamaskHeight+2), Qt::AlignCenter, tr("Some Text..", "header with description")); m_image = image;
and I have a
translate()
method setup like so:bool TheObject::event(QEvent *event) { if (event->type() == QEvent::LanguageChange) { retranslate(); } return false; } void DataMaskObject::retranslate() { }
how can I go about re-translating the text of
m_image
? -
Hi,
Put the image setup code in its own method and call it from the constructor and retranslate.
-
No, you have to redraw it as setText is for metadata.
What is the issue with the solution I suggested ?