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
Trusted Contributor
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers
Accepted Solution

maxWidth is NOT set

I've been getting this error message in my terminal:

 

 default 9000 "WARNING: maxWidth is NOT set, returned value cannot be trusted"

 

I know what it means but I have no clue where to set it or which one is giving me the error in my QML. can anyone tell me how to figure out which control is giving me the error.

 

Thank you

Developer
Posts: 103
Registered: ‎12-31-2012
My Device: Blackberry 9810
My Carrier: Verizon

Re: maxWidth is NOT set

I doubt if this is an error and more like a WARNING given when trying to access/use a property (getMinWidth()) that has not been already set...

 

 

 

Highlighted
Trusted Contributor
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers

Re: maxWidth is NOT set

you are right it's not an error it's a warning I get in the terminal but I would like to remove them so that's why I was asking. I always feel like I'm falling when my projects aren't compiling without error/warning
Developer
Posts: 103
Registered: ‎12-31-2012
My Device: Blackberry 9810
My Carrier: Verizon

Re: maxWidth is NOT set

[ Edited ]

TO know the exact cause of the warning.. i guess you ll have to share the code... Smiley Happy

Developer
Posts: 216
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

Re: maxWidth is NOT set

Select maxWidth or write it in a comment and select it.

 

// maxWidth

Then in Momentics select Search > Text > Project. In the search results you will see all occurrences of maxWidth. Then you can eliminate where you access it.

Trusted Contributor
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers

Re: maxWidth is NOT set

Ok I finally understood by reading all your posts. I was setting, in my QML, preferredWidth: maxWidth. I was doing this cause I thought it would use the complete width available. As soon as I commented that the Warnings went away. Is there something else I need to do in preferredWidth so that the container use the full width available, or by default if nothing the complete space is taken ?

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: maxWidth is NOT set

Instead of setting preferredWidth to maxWidth, use preferredWidth: Infinity

The maxWidth will, if set, still override that of course.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Trusted Contributor
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers

Re: maxWidth is NOT set

Thnak you Peter
Trusted Contributor
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800
My Carrier: Rogers

Re: maxWidth is NOT set

I tried your Infinity variable but it squishes out my image. Here is a sample code

 

import bb.cascades 1.0

Container {
    layout: StackLayout {
        orientation: LayoutOrientation.TopToBottom
    }
    preferredHeight: 150
    preferredWidth: Infinity
    Container {
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }
        bottomPadding: 10
        topPadding: 10
        leftPadding: 10
        ImageView {
            preferredHeight: 80
            preferredWidth: 80
            imageSource: "asset:///images/following.png"
        }
        Container {
            layout: DockLayout {
            }
            preferredHeight: 80
            //preferredWidth: 600 
            Label {
                verticalAlignment: VerticalAlignment.Bottom
                text: "Test"
            }
            Label {
                translationX: 100
                verticalAlignment: VerticalAlignment.Bottom
                text: "Test2"
            }
        }
    }
}

 Here my problem is if I don't set the third container to a preferedWidth: 600 I don't get to see the Test2. And if I set the preferedWidth: Infinity instead of 600 my image on the left is getting squished. Is it me that don't understand how it's suppose to work?

 

Thank you

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: maxWidth is NOT set

The preferredWidth: Infinity trick is, I believe, mainly useful in a ListView when you put it on the root visual node for a custom ListItemComponent. I'm not sure why I suggested it here without any sign you were working with a ListView.

For other cases, there should be no need of that. I think you're dealing with instances where you should be adding a layoutProperties element, probably layoutProperties: StackLayoutProperties { spaceQuota: 1}. You'd do that for example in one of the items in a StackLayout to have it expand in the layout direction to fill the space remaining after other items were given their preferred widths.

Alternatively, if you're trying to expand something to fill the available space *perpendicular to* the layout direction, then you'd probably want the horizontalAlignment: HorizontalAlignment.Fill to expand across the width when doing a TopToBottom layout (or the vertical equivalent to expand to the full height when doing a LeftToRight layout).

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!