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: 4
Registered: ‎02-20-2013
My Device: z10
My Carrier: blackberry

how to Measuring QString width in bb10

hi guys,

 

i want to get the QString width in bb10, below is the code i used.

 

QFont font = QApplication::font();
font.setPointSize(14);
font.setStyleStrategy(QFont::ForceIntegerMetrics);
QFontMetrics fm(font);
double x=fm.width("ABC");
fprintf(stderr, "Width of ABC is %f\n",x);

 

but i got an segment fault, some body help me why this happened?

below is the stack

 

Thread [1] (STOPPED) (Suspended : Signal : SIGSEGVSmiley Frustratedegmentation fault)
initializeDb() at 0x793a5a72
QFontDatabase::findFont() at 0x793a7428
QFontDatabase::load() at 0x793a816e
QFontPrivate::engineForScript() at 0x7938fe8c
QTextEngine::fontEngine() at 0x793b641c
QTextEngine::shapeTextWithHarfbuzz() at 0x793b6fd6
QTextEngine::shapeText() at 0x793b78e2
QTextEngine::shape() at 0x793b7c38
QTextEngine::width() at 0x793ba98c
QFontMetrics::width() at 0x793a2784
HelloCascadesApp::HelloCascadesApp() at hellocascadesapp.cpp:56 0x8049ba2
main() at main.cpp:27 0x804a472

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to Measuring QString width in bb10

the last time i tried that it did not work, i have not found a solution to get the font width so far.

regarding your segfault: debug and check the stacktrace.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
New Contributor
Posts: 4
Registered: ‎02-20-2013
My Device: z10
My Carrier: blackberry

Re: how to Measuring QString width in bb10

why blackberry do not support this interface?

Developer
Posts: 16,992
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: how to Measuring QString width in bb10


leeli wrote:

why blackberry do not support this interface?


good question, my colleague added a feature request for that half a year ago. maybe you can find it in jira and add votes to it.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 271
Registered: ‎05-29-2013
My Device: BlackBerry Z10
My Carrier: MTS

Re: how to Measuring QString width in bb10

According to roadmap: https://developer.blackberry.com/cascades/downloads/roadmap/
custom fonts may bring font metrics feature.
I have also received a segfault when tried to use QFontDatabase.
-------------------------------------------------------------------------------
NSR Reader for BlackBerry 10 @NSRReader on Twitter
Me @xelfium on Twitter