PDA

View Full Version : Blink Text in QTextEdit



Vaishnavi
25th September 2012, 16:15
I'm working with Qt 4.6 on Ubuntu platform. I'm not able make text blink in QTextEdit/QLabel. I tried using a timer and signal-slot connection. It works fine. But, is there any other method through which I would be able to achieve this? Could someone help me with this?

ChrisW67
25th September 2012, 23:51
Blinking text! The early 90s called and want their blinking text back.

I tried using a timer and signal-slot connection. It works fine.
So, you have a solution, but I cannot think of anything more annoying (in a UI) than trying to edit text that is blinking. There is no setBlinkingText() function if that is what you are looking for.

Vaishnavi
26th September 2012, 06:53
Thanks Chris! But, I wont be editing the text. I'm just using the QTextEdit class to display the text. So, would you recommend the timer-signal-slot method as the apt solution?

ChrisW67
26th September 2012, 08:48
Yes, subclass QTextEdit/QLabel and give your subclass a setFlashRate() and set a timer based on that (zero might be don't flash) or similar and you should be good to go.

BalaQT
26th September 2012, 08:57
hi,

Thanks Chris! But, I wont be editing the text. I'm just using the QTextEdit class to display the text.
Then you can use QLabel instead of using QTextEdit.

Yes timer is the simple way to implement blink

hope it helps,
bala

pradeepreddyg95
26th September 2012, 19:25
hi chris i am unable to find setflashrate() in Qlabel/QtextEdit i am using qt-4.8.2 if it is possible to scroll text in Qlabel plz update us .....

wysota
26th September 2012, 21:37
hi chris i am unable to find setflashrate() in Qlabel/QtextEdit i am using qt-4.8.2 if it is possible to scroll text in Qlabel plz update us .....

This is a method one is supposed to implement first.

Vaishnavi
27th September 2012, 09:14
Thanks Bala

Vaishnavi
21st November 2012, 06:47
Hi Chris... The blink feature works fine for me. But, the characters occupy varying number of pixels. This makes the blink imperfect. Is there any way to set the pixel size uniformly for all the characters (including a blank space). I tried setPixelSize under QFont class... but I don't get the expected result. Could you please help me with this?

Gokulnathvc
21st November 2012, 07:48
Have you tried with setCursorWidth() ?

Vaishnavi
21st November 2012, 08:43
Yes I have tried it. But that changes only the width of the cursor. I want to set the pixel width for the characters.

Gokulnathvc
21st November 2012, 08:57
Use http://doc.qt.digia.com/3.3/qfontmetrics.html

Vaishnavi
21st November 2012, 10:33
Thanks Gokul. QFontMetrics class has options only to read the properties of the font. It seems there is no way to set the font properties using this class.

wysota
22nd November 2012, 04:44
Hi Chris... The blink feature works fine for me. But, the characters occupy varying number of pixels. This makes the blink imperfect. Is there any way to set the pixel size uniformly for all the characters (including a blank space). I tried setPixelSize under QFont class... but I don't get the expected result. Could you please help me with this?

Use a fixed width font (e.g. Courier) instead of a proportional one (e.g. Arial).

Vaishnavi
22nd November 2012, 08:12
Thanks. I have tried this. It doesn't work yet :(

ChrisW67
22nd November 2012, 09:19
Hi Chris... The blink feature works fine for me. But, the characters occupy varying number of pixels. This makes the blink imperfect.
:confused: By blink you mean alternating draw text, don't draw text. How does font size have anything to do with this?

Vaishnavi
22nd November 2012, 10:07
My requirement is as mentioned below.
I have a string : "Welcome Good Morning".
I want only the word "Good" to keep blinking. I'm successful in achieving this. I have done some string manipulations for this.
While making the text to blink, the word "Good" appears and disappears alternatively. When it disappears, the 4 characters(G,o,o,d) are replaced by 4 blank spaces. In this case, the no.of pixels occupied by a blank space and the no. of pixels occupied by other characters do not seem to match. Hence the appearance is not as expected. The text appears to be moving while blinking. I would like to resolve this issue. I believe this could be resolved if the pixel size for all the characters is set to the same value. I request your help to obtain an appropriate solution.

amleto
22nd November 2012, 10:14
as already mentioned, using a fixed-space font should resolve that issue.

Vaishnavi
22nd November 2012, 10:26
I tried Courier. But it doesn't impose much effect.

Added after 9 minutes:

I tried again. Courier works fine. Thanks to all :)