02-07-2013 07:38 AM
How can i find the absolute position of Text end it can be one or more,
at the position i need to inseart the image of font size as it mathces the regular view sequiential - image as custom image
Please help us to find the text position and even for one more function i required the finding the text length
I want to make one will be right and another will be left how I can i align is their any way with out finding the label or text width?
thanks
Solved! Go to Solution.
02-08-2013 08:11 AM
Hi All,
Please help me,
* to solve finding the position of the text and
* using custom font and
* align the two label as left and right both will have variable width(dynamic data),
how can i align them in the view please sugession on the layout to be followed
thanks
02-08-2013 10:16 AM
This should help aligning your labels Layouts, depending on how you wanted it done you could go with an absolute layout, dock or stack (lets you align them top to bottom or left to right)
I'm not too sure about the rest, however to determine the length of text I would think that you could store the text in a string and then somehow programmatically count each letter & have it return a result.... not exactly sure on how to do that but it's an idea ![]()
02-09-2013 07:33 AM - edited 02-09-2013 07:35 AM
Thanks
Note My Problem in like two label is dynamic and consider the one divider is center aligned with 10 px on both side and one label should be at the beginning of the divider and another label end should match the end of the divider
String1 String2
-------------------------------------
Similar to this
now consider string to is dynamic data
some times
1)
String1 str2
------------------------------------------
2)
String1 stringstr2222
------------------------------------------
it happening I want to fix them as label end as the divider end
thanks for you help
02-15-2013 09:07 AM
thanks
Here I have to use mutiple layout saying dock layout and stack layout
02-15-2013 03:54 PM
I just found another way to get the absolute position of a controller. Don't know it works for you or not.
// Ensure that the x/y position is really 0,0 otherwise using the
// translationX/translationY properties does not work as expected.
AbsoluteLayoutProperties *props
= qobject_cast<AbsoluteLayoutProperties*>(m_controll
02-23-2013 07:23 AM
I want to find the text end length, for example
Consider the "Hello world Sample" I need to find the end position of the text and need to insert a custom image in that position with left padding as 10 pixels
Hello World sample
but here I don't want to insert the emotion instead it will contain custom image.
02-23-2013 11:21 AM
One solution is you put two fields: text and image and using left to right layout. It is the better solution.
Another solution is to get the width of string:
Have not tested this solution yet cause I don't have environment right now, can you have a try?
QFontMetrics metrics(label->font());int pixelWidth = metrics.width(label->text());
or
int pixelWidth = label->fontMetrics().width(label->text());
02-23-2013 11:26 AM - edited 02-23-2013 11:28 AM
some times
1)
String1 str2
------------------------------------------
2)
String1 stringstr2222
------------------------------------------
you can use the solution as layout containers such as "String1 stringstr2222" is put into one container then put dividor into another container which is under that container. You can set up the same preferwidth for these two containers.