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
New Contributor
Posts: 6
Registered: ‎07-15-2013
My Device: Z10 & Q10
My Carrier: EE

How to make fixed width label in cascade?

I am trying to make a fix width text  element. I tried with QFontMetrix but failled to make it working due to lack of knowledge of QT/BB10 integration. 

Cascade's TextField came up with a solution but stuck at center alignment, Please help
My code with TextField:

 

Container {

horizontalAlignment: HorizontalAlignment.Fill
layout: DockLayout {
}
preferredWidth: 600
verticalAlignment: VerticalAlignment.Center
TextField {
enabled: false
backgroundVisible: false
autoFit: TextAutoFit.FitToBounds
text: textToDisplay
textStyle.color: Color.Black
textStyle.fontSize: FontSize.Large
textStyle.fontWeight: FontWeight.W500
}

}

Developer
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: How to make fixed width label in cascade?

Use setMaxWidth() and setMinWidth() for Label
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter
Regular Contributor
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user
My Carrier: none

Re: How to make fixed width label in cascade?

If you can switch to a StackLayout you can use

StackLayoutProperties.

 

In C++ I do something like this:

    float sq = 1.0;
    StackLayoutProperties::updateFor(label1).spaceQuota(sq);
    StackLayoutProperties::updateFor(label2).spaceQuota(sq);
    StackLayoutProperties::updateFor(label3).spaceQuota(sq);

 

Sorry do not know how to do it with DockLayouts

 

 

New Contributor
Posts: 6
Registered: ‎07-15-2013
My Device: Z10 & Q10
My Carrier: EE

Re: How to make fixed width label in cascade?

Thanks for the reply Smiley Happy

setMaxWidth() does not "fit" the text by reducing font size. That's why I have tried TextField with autoFit: TextAutoFit.FitToBounds.
New Contributor
Posts: 6
Registered: ‎07-15-2013
My Device: Z10 & Q10
My Carrier: EE

Re: How to make fixed width label in cascade?

spaceQuota is also not a solution for dynamic text.

Thanks anyway