Hi
Is there a way of making some text within a QTextEdit non editable?
I want to insert some text programatically but prevent the user from editing this text.
thanks
Hi
Is there a way of making some text within a QTextEdit non editable?
I want to insert some text programatically but prevent the user from editing this text.
thanks
Thanks for the hint
How would I make my QTextObject read only?
You can start by reading the docs, especially the Text Object Example.
Hi
OK, I have read the relevant docs and started to implement my own text object for inserting a string.
I can now get this displayed, but am struggling with how to correctly implement the 'intrinsicSize' method.
inside this method I can obtain the string to be inserted and then i tried to calculate the size required to display it
Qt Code:
qreal pointSize = fmt.fontPointSize(); size.setHeight(pointSize); size.setWidth(pointSize*str.length());To copy to clipboard, switch view to plain text mode
but he size is always 0.
I would appreciate any hint as to how to correctly implement this
Thanks
GrahamLabdon (10th October 2011)
Hi
Thanks for the help
Inside the 'intrinsicSize' method I retrive the font by -
But this always returns the same thing, I want the font being used in the document at the point that I insert the text.Qt Code:
To copy to clipboard, switch view to plain text mode
Why does my code not work?
Thanks
This returns the text format of the whole block. If you want the format for your item, use QTextObject::format() and convert it to the proper type. You can also use QTextCursor::charFormat().
Hi
Within the intrinsicSize method I cannot get on object of type QTextObject or QTextCursor.
returns a null pointer.Qt Code:
To copy to clipboard, switch view to plain text mode
QTextCursor belongs to the QTextEdit class which does not seem to be available in this method
Am I missing something?
Graham
QTextCursor doesn't belong to QTextEdit class. You can have as many cursors as you want, have a look at available constructors. And I have no idea what your objectForFormat() call was supposed to do. You are implementing QTextObject subclass so just calling format() will return a QTextFormat which you can then convert to another type using the API available in QTextFormat.
OK now I am confused
You say I am implementing a QTextObject subclass, but I am just following the TextObject example that implements
QTextObjectInterface.
Where should I be creating a QTextObject ?
Thanks
Bookmarks