Recent

Author Topic: QT and TMemo and fonts  (Read 5716 times)

sfeinst

  • Full Member
  • ***
  • Posts: 186
QT and TMemo and fonts
« 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).

zeljko

  • Hero Member
  • *****
  • Posts: 1081
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT and TMemo and fonts
« Reply #1 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.


sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: QT and TMemo and fonts
« Reply #2 on: January 27, 2012, 06:33:38 pm »
Thanks for looking into this.

zeljko

  • Hero Member
  • *****
  • Posts: 1081
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT and TMemo and fonts
« Reply #3 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.

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: QT and TMemo and fonts
« Reply #4 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.

zeljko

  • Hero Member
  • *****
  • Posts: 1081
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT and TMemo and fonts
« Reply #5 on: March 19, 2012, 08:18:29 pm »
But I've fixed it in the meantime (problem was RTFM) :)
See r36171

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: QT and TMemo and fonts
« Reply #6 on: March 20, 2012, 12:30:58 am »
Glad I only threatened to change my code instead of actually doing it  :D

zeljko

  • Hero Member
  • *****
  • Posts: 1081
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT and TMemo and fonts
« Reply #7 on: March 20, 2012, 07:50:29 am »
btw. you cannot capture paste under qt because there's no signal for that.