Solved Subclassed QPlainTextEdit, how can call in other class?
-
@Panoss
Hi
Does notifierText have a Q_OBJECT macro ? -
Hi mrjj.
I demoted it to QPlainTextEdit, I don't use the notifierText class. -
@Panoss
Hi :)
ok so sn_txt is now a 100% normal QPlainTextEdit and not your class?
Did you clean, rebuild all after changing back? -
Yes it 's a pure QPlainTextEdit .
I cleaned and rebuild but the same happens. -
@Panoss
show the new current code then.
It normally just works. -
This is the connection in RepairDevices' constructor:
connect(ui.sn_txt,SIGNAL(textChanged(QString)),this,SLOT(setDirty(QString)));
This is the declaration of the function:
public slots: void setDirty(QString txt);
This is the function:
void RepairDevices::setDirty(QString txt) { qDebug() << "text=" << txt; }
-
When I change to textChanged(), it works.
But I don't have the text of the sn_txt.And I see here: void QPlainTextEdit::textChanged()
-
@Panoss said in Subclassed QPlainTextEdit, how can call in other class?:
textChanged
i dont think it has version where it emits the whole text. lineEdit has.
so you must use QPlainTextEdit::textChanged() and
void RepairDevices::setDirty()
{
qDebug() << "text=" << ui->plaintext->toPlainText();
} -
The reason I subclassed it, was because I wanted the class to connect to RepairDevices 's slot.
(that is, the code: connect blah blah to be in the class)
This is not possible, so it's canceled.
Thank you for your help. -
Well the normal signal does not have QString but in a subclass
you could easy make a new signal that would have and
then emit it in the subclass and it would be as you wanted.