Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
krishnan8727
Posts: 63
Registered: ‎10-06-2010
My Device: Not Specified
Accepted Solution

How can i find the absolute position of Text end it can be one or more,

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

Please use plain text.
Regular Contributor
krishnan8727
Posts: 63
Registered: ‎10-06-2010
My Device: Not Specified

Re: How can i find the absolute position of Text end it can be one or more,

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

Please use plain text.
Developer
slashkyle
Posts: 818
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: How can i find the absolute position of Text end it can be one or more,

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 :smileywink:

Please use plain text.
Regular Contributor
krishnan8727
Posts: 63
Registered: ‎10-06-2010
My Device: Not Specified

Re: How can I find the absolute position of Text end it can be one or more,

[ Edited ]

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

      

Please use plain text.
Regular Contributor
krishnan8727
Posts: 63
Registered: ‎10-06-2010
My Device: Not Specified

Re: How can i find the absolute position of Text end it can be one or more,

thanks

 

Here I have to use mutiple layout saying dock layout and stack layout 

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How can i find the absolute position of Text end it can be one or more,

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_controllor->layoutProperties());




p(^_^)q
Good good study, day day up
Please use plain text.
Regular Contributor
krishnan8727
Posts: 63
Registered: ‎10-06-2010
My Device: Not Specified

Re: How can I find the absolute position of Text end it can be one or more,

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 :manlol: but here I don't want to insert the emotion instead it will contain custom image.

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How can I find the absolute position of Text end it can be one or more,

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());



p(^_^)q
Good good study, day day up
Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: How can I find the absolute position of Text end it can be one or more,

[ Edited ]

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.




p(^_^)q
Good good study, day day up
Please use plain text.