QPushButton tooltips inserts a line break without me specifying it - c++

I have code like this:
//QPushButton*
myButton->setToolTip("ReallyLong String lolol<br>shortString");
And what happens is that sometimes, when I have a long and a short string, the long string gets cut off at some point and continues on the next line,so I end up with 3 lines, something like this:
ReallyLong String lolol shortString
Why is this happening? There doesn't seem to be a way to control it.

Why is this happening? There doesn't seem to be a way to control it.
From the QToolTip man page:
Rich text displayed in a tool tip is implicitly word-wrapped unless
specified differently with <p style='white-space:pre'>.

Related

QListWidget very long text

I'm asking this question because i dont know how to google it, i dont find the right keywords.
I have a QListWidget with strings inside. The strings are very long and if i disable horizontal scrolling, which is what i want, then the text ends with ... because it is too long.
I would like to have the text to display the end of the text and the beginning like:
This is very long text to This is ... text instead of This is very long ...
Is there any simple way to achieve this without having to manipulate the string? I need the full string afterwards and i dont want to store extra data. Any help is appreciated.
There is indeed a very easy solution: Lock for TextElideMode and Qt::ElideMiddle (setTextElideMode ( Qt::TextElideMode mode )).

Visual Studio C++ removing last character from string

I need a little help with my calculator program. I have created the code for the main buttons like the numbers 0-9 and the arithmetic operators to make it perform simple calculations.
What I'm having problems with right now is making the CE button work, after clicking the CE button I need the last entered character to be removed from the display label.
I have tried to adapt this code somehow, but it doesn't work:
lblResult->substr(0, lblResult->size()-1);
I know I'm doing somehting wrong here, can you please help me?
Thanks in advance
...Now that we know that lblResult is a System.Windows.Forms.Label, we can look at the documentation.
A Label has a Text Property, which is a String^ (i.e. a string reference).
For what you want to do, the Remove Method of String is appropriate. But note in the documentation it says that it "Returns a new string in which a specified number of characters from the current string are deleted." This means that it does not modify the string, but returns a modified copy.
So to change the label's text, we need to assign to its Text property what we want: the current string with all of the characters except the last:
lblResult->Text = lblResult->Text->Remove(lblResult->Text->Length - 1);
lblResult->resize(lblResult->size() - 1);
In this case you can use components Remove and Length methods.
Use the following code to access the components text:
component->Text
Than remove the last character of string by accessing Remove and component Length method
= component->Text->Remove(component->Text->Length - 1)
I hope you find this useful.
Just asking the obvious -- the whole statement is
*lblResult = lblResult->substr(0, lblResult->size()-1);
right?

CRichEditCtrl OnUpdate(): how to know the start and end positions when a paste is received?

I'm using a CRichEditCtrl to edit a computer language, and on every change to it I'm calling SetSelectionCharFormat on the current line of text (as reported by LineFromChar(-1)) to highlight the syntax. (EG: comments in green, section headings in a bigger font, compilation errors in red, etc.) Note this language doesn't have multi-line features such as a C comment where typing /* on one line makes following lines part of a comment too; for any given character change I only need to change the color of the current line.
It all looks like its working fine.
However there are some weird issues. One is, when multiple lines of text is selected from somewhere else, and pasted. My OnUpdate() is called but is naively assuming that the only line that potentially needs re-formatting is the one returned by LineFromChar(). That suffices when the user is typing character by character, but it means that after receiving a multi-line paste, the program only reformats the last line of the pasted text. How can it know where the start of the insert was?
OnUpdate is called inside the Paste operation.
It should be possible to subclass the RTF control and to intercept the WM_PASTE message. If WM_PASTE is not used internally it might be possible to use EM_PASTESPECIAL. If even tis message isn't sent, you have to interecept the Ctrl+V that causes the paste Operation.
Than you can determine the starting position of the paste operation.
Spy++ might be helpful to determine the message flow in the RTF control.

How to prevent OpenOffice/LibreOffice Calc from changing what you input (data, numbers,...)

Basically, I want LibreOffice Calc to do what I tell it, not what it wants.
For example:
when I input 1.1.12, I want to have 1.1.12 in that cell, not 01.01.2012 or whatever.
when I input 001, I want to have 001 in that cell, not 1
and so on and so forth
I want it to never ever touch my data until I explicitly tell it to. Is that possible at all?
I know I can set format of a cell to text. It doesn't help at all. Example:
Input 1.1.12, it gets displayed as 01.01.12, format as text, it becomes "40909", original input is lost
Format empty cells as text. Paste "000 001 002 ..." separated by line breaks. Displays "0 1 2 ..."
I know I can write ' in front of anything for it to be forced text. Again it doesn't help, because when I paste in text, I cannot have ' auto-appended to it.
I hope this is possible. I tried googling for different problems and never found a good answer.
If you want your input to be interpreted as text and preventing Calc to do fancy (and annoying) things with your input, you have to change the format before entering any value.
Select the cells/columns/rows.
Right-click 'Format Cells...'
Select the tab 'Numbers'
In the list 'Category', select 'Text' (the last option)
Select the format '#' (it is the only one in this category)
Click on 'Ok'
You may need to tweak the 'autocorrect' options as well. Go to 'Tools > Auotcorrect Options...'. Here is a link that may help: https://help.libreoffice.org/Calc/Deactivating_Automatic_Changes
I understand your problem with pasting pure unformatted text. This may be more work than you like (we can try to automate that later) but when I paste data from Notepad, I am prompted with an import screen as you can see below. Select the column header(s) and then select Column type: Text. This should solve your paste/import problem. An alternative is to handle this with an AutoHotKey script.
Oh b.t.w. the # is the format type for text, just like you have HH for 24 hour or ddd for weekdays...
When you are importing, you're given a bunch of options. Select "Quoted field as text" so any text inside quotes is treated as text which is interpreted by LibreOffice as sacred and they do not modify it in the way they they modify something that they identify as number
When you have your data in the clipboard click Edit -> Paste as... in main menu. In next window choose "Paste as text". All your data will be pasted as is.
I initially arrived at this page with a very similar (but not identical) problem. I am posting the solution here for the benefit of those who might be visiting with the same issue.
Every time I would save, close, and then re-open my .XSLX spreadsheet in OpenOffice, it would delete the spaces I had entered in between text. For example:
"Did not attend" would become "Didnotattend".
"John DOE" would become "JohnDOE", etc.
Specifying "text" (#) as the format (as recommended above) did not help me, unfortunately.
What ultimately did solve it was saving it as an .ODS file instead of .XSLX .
just simply put character ' before the text, '0.1.16 and calc will interprate it as text data
My issue was currency, properly formatted would change to a much larger number if the numbers entered could represent a date; such as 4.22 becoming $42,482. I discovered that adding a trailing zero solved the problem.
I had pasted numbers from another site and it kept coming up with dates. I just messed around and hit the arrow that's on the paste board to give me the option of unformatted text or HTML format. I selected unformatted, a window opened to show me the text I wanted so I pressed o.k.

c++ create text fits edit box

Well.. I know that title is not that clear, I couldn't think of better one.
I wanna know how to do this...
when you have edit box and it only can show 10 characters.
Something like this
ssssssssss
let just say i have more than 10 characters. Some of them will go in the back.
Like we have this string "123456789010" it will show just these ones "3456789010".
My problem is that some characters are small and don't take that much space and some do.
So i can't find a way to break the string and get some characters in the back.
any idea?
Try this in Style type in edit box use ES_MULTILINE for use multiple lines.
edit1=CreateWindowA("edit","edit box",WS_CHILD|WS_VISIBLE|WS_BORDER|ES_MULTILINE,120,160,200,200,hWnd,(HMENU)IDI_EDIT,hInstance,0);
You can calculate the display-length of the string in your control (there are several function for that) and adjust the size of the control accordingly.
you only want to see the far left or far right?
here is your string "0123456789"
you can only display 5 values due to pixel size of box....
do you want it to be "...56789" more like "56789"
or "01234..." more like "01234"?