I am using a Spark Label component to display some text. The label has a set width and height. I am updating the text externally to give the impression text is being typed into it. When I give it the following text:
fredFlintstone#yahoo.com
It shows only the beginning of the text like this:
fredFlintstone#yah
I would like to to show the end of the text like this:
tone#yahoo.com
There are no apparent settings in the .setStyle() call.
take care,
lee
Related
i am trying to accomplish the following behavior with a QML TextArea:
I want single Words in the Text to be colored differently
I want the "select"-functions to be working for automated scrolling (user interaction is disabled)
There is a stream of text in the TextArea where one Word needs to be selected(highlighted). The user is requested to input some text elsewhere and press enter to proceed (not part of the question). After that the selection jumps to the next word and the last selected word is either colored green or red. There is only a small portion of the text visible (a few lines, managed by the TextArea height – not part of the question) and i need the text to scroll if the next word is out of that visible range .. therefore the selection is quite helpful because all interaction from the user – to scroll or select or whatever – is disabled (disabling is not part of the question)
my main problem is: if i use textFormat: TextEdit.RichText i can easily color the text how i like it to be (<font color=\"green\">{}</font>) but i cannot use the "select"-functions anymore because – as i would guess – the selection works on the "plaintext" and cannot correspond to the "richtext"-selection? Anyway selectWord() etc. does not work QTextCursor::setPosition: Position '-1' out of range is the result. But if i disable the RichText i don't know how to color the text. Maybe i could live without the selection if i could detect the current word – which would be colored blue etc. – and scroll if its out of the visible area to "fake" the selection behavior, but that's just a third option.
I would really either know how to color non-Rich Text or how to select Rich Text in a TextArea.
You can use QSyntaxHighlighter to highlight the words independent of the selection. See QQuickTextDocument and How to implement rich text logic on QML TextEdit with QSyntaxHighlighter class in Qt for more details.
I have a dynamically built string that is sometimes too long, but still needs to be displayed fully to the user. I would much rather have the text scroll than creating a tooltip for it.
I have creating a label with this:
Label text = new Label("hello there i hope this text is long enough to take up space");
TranslateTransition tran = new TranslateTransition(Duration.millis(75000));
tran.setNode(text);
tran.setByX(-400);
tran.setInterpolator(Interpolator.LINEAR);
tran.setCycleCount(Timeline.INDEFINITE);
// add the text
tran.play();
One, when I do this, if the text is "this is really long" and it's shortened to "this is really..." then when the label scrolls, the text remains "this is really...". Another thing is this scrolls the label away, changing the x position of the element. Is there a way to just change the text will a scroll instance?
Also, is there a way to programatically determine if a given text is going to be too large for a specified area?
The most simplest method could be "marquee":
http://www.quackit.com/html/codes/html_marquee_code.cfm
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee
http://www.sitepoint.com/web-foundations/marquee-html-element/
But it´s nonstandard: http://www.w3.org/TR/css3-marquee/
A better method is CSS3: http://www.hongkiat.com/blog/css3-animation-advanced-marquee/
I have a tab widget with two tabs in it in my Qt application. When I set the label text for a tab to a long word like 'Difference', some of the text goes out of the boundary of the tab and is not shown. How do I fix this so that the entire label text fits exactly in the tab?
Thanks,
Rakesh.
Qt receives that style from OS. By default on Windows text isn't truncated. You can set it manually using
QTabWidget::setElideMode( Qt::ElideNone );
I think elideMode would be helpful for you.
Try setting the value to Qt::ElideNone which will not show the ellipsis in the text, so I am guessing it might show the entire text.
How would I display text in something like QTextEdit starting from bottom up? QTextEdit starts writing at the top filling down to bottom. I want to start from the bottom and then pushing the previous text up as more text is added. I figure I could hack it and simply fill the field with nextlines to reach the bottom then reprinting whatever was written before again when text is to be added, but I wouldn't want to do that unless there isn't any other way.
insertPlainText inserts text at the current text position. You could move the cursor to the start of the docuement using the moveCursor function.
Every time you want to add some text do the following:
textEdit->moveCursor(QTextCursor::Start);
textEdit->insertPlainText(textToBeAdded);
I want to display a big string in a Qlablel for this I simply have created a label in the Qt GUI editor.
Then set the string with the Wordwrap property to "ON".
Here text is not coming to the next line itself. Instead, it's crossing the view region.
However, if I give an "\n" it works well.
How do I put up the big string in a label to display in a visible region?
label->setWordWrap(true);
See the QLabel::setWordWrap(bool on) documentation.