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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
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: 17,026
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
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: 17,026
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