hi,
In QTextEdit if we enter ": )" it needs to change as image .. please guide me if u have any idea?
Thanks in advance.
Thanks & Regards,
Sivambigai.M
hi,
In QTextEdit if we enter ": )" it needs to change as image .. please guide me if u have any idea?
Thanks in advance.
Thanks & Regards,
Sivambigai.M
React on text changed signals or events.
Use setHtml and replace the :-) string with some html image tags.
hi
Thanks for your idea..
i have used
QObject::connect(textEdit, SIGNAL(textChanged()), this, SLOT(changePixmap()),Qt::QueuedConnection) ;
void CSmsWidget::changePixmap()
{
QString text =textEdit->toPlainText();
if (Qt::mightBeRichText(text)){
textEdit->setHtml(text);
}
}
but this is not working.. any idea?
Thanks in advance.
Do you think images come out of thin air?
replace the text :-) with something like <img source="...">
chris_helloworld (16th November 2010)
hi
Thanks for your reply
void CSmsWidget::changePixmap(){
QString text =textEdit->toPlainText();
if (text.contains(": )")){
QImage img(":/images/happy_smilie.png"); // todo: generate image in memory
m_currentMsg->document()->addResource(QTextDocument::HtmlResource, QUrl("happy_smilie.png" ), img);
text.replace("","<p><img src=\":/images/happy_smilie.png\"></p>");
m_currentMsg->setHtml(text);
}
}
This is working once again Thanks
Added after 6 minutes:
hi,
In the above code if i have entered two smiley character like this "hi (first one ) Hope you are fine (second)" .
In QTextEdit after entering the second smiley first image will get vanished.
Is it the problem because of both the smilies refers to the same image ?
Thanks in Advance
Last edited by sivambigai; 15th November 2010 at 10:02.
You are doing that in most possible wrong way. When you have multiple smileys then strange things will happen.
Take a look on that (QTextCursor is proper way of modifying editors/QTextDocument content):
Qt Code:
void CSmsWidget::changePixmap() { if (!cursor.isNull()) { cursor.insertHtml("<img src=\":/images/happy_smilie.png\">"); } }To copy to clipboard, switch view to plain text mode
hi MarekR22,
Thanks for your help
Please visit https://youtu.be/QXDfhien_vM
Please visit https://youtu.be/QXDfhien_vM for Emoticon widget to develop in Qt C++.
Bookmarks