Lazarus

Programming => Widgetset => QT => Topic started by: sfeinst on January 24, 2012, 04:42:13 pm

Title: QT and TMemo and fonts
Post by: sfeinst on January 24, 2012, 04:42:13 pm
I have an app which uses a TMemo.  From what I understood, TMemo supports display of one font at a time.  I highlighted some text on a web page and pasted it into the TMemo.  On Windows, it works as expected and the text displays with the font of the TMemo.  When I do this in QT on Linux, the text displayed using different fonts (as it appeared on the web page).

I am using PasteFromClipboard of the TMemo to paste the text.

Am I running into a bug/feature of TMemo on QT (I'm guessing the memo control being used by QT supports multiple fonts).
Title: Re: QT and TMemo and fonts
Post by: zeljko on January 27, 2012, 10:25:43 am
Yes, you reached half-baked class problem from qt.
http://doc.qt.nokia.com/4.7/qtextedit.html (it works with plain text (property is setted up), but when you paste something it does not take into account that property and it paste complete html and then it renders that part as rich text).
So that's why they introduced QPlainTextEdit class (it was easier than fix few bugs in QTextEdit ..i guess :) ).

http://doc.qt.nokia.com/4.7/qplaintextedit.html
That class is probably exact class we need for TMemo, so I'll try to implement TMemo handle via QPlainTextEdit and see if it helps.

Title: Re: QT and TMemo and fonts
Post by: sfeinst on January 27, 2012, 06:33:38 pm
Thanks for looking into this.
Title: Re: QT and TMemo and fonts
Post by: zeljko on March 19, 2012, 08:03:15 pm
Yes, I've tried to fix it but QPlainTextEdit is missing alignment() and setAlignment() properties .. so not for 1.0.
Title: Re: QT and TMemo and fonts
Post by: sfeinst on March 19, 2012, 08:17:48 pm
Understood.  I may just add code which captures the paste first, stores in string and then pastes the string, so there won;t be any formatting.  A little bit of a kludge, but should work.
Title: Re: QT and TMemo and fonts
Post by: zeljko on March 19, 2012, 08:18:29 pm
But I've fixed it in the meantime (problem was RTFM) :)
See r36171
Title: Re: QT and TMemo and fonts
Post by: sfeinst on March 20, 2012, 12:30:58 am
Glad I only threatened to change my code instead of actually doing it  :D
Title: Re: QT and TMemo and fonts
Post by: zeljko on March 20, 2012, 07:50:29 am
btw. you cannot capture paste under qt because there's no signal for that.