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
Developer
slant
Posts: 32
Registered: ‎07-31-2009
My Device: Not Specified
Accepted Solution

Display Width and Height

How do you get the display width and height?

 

ie in java Display.getWidth()

Please use plain text.
Developer
slant
Posts: 32
Registered: ‎07-31-2009
My Device: Not Specified

Re: Display Width and Height

For anyone needing to do this here's how I did it

 

	screen_context_t m_screen_cxt;
	int count = 0, size[2];
	screen_display_t *displays;

	screen_create_context(&m_screen_cxt, SCREEN_APPLICATION_CONTEXT);
	screen_get_context_property_iv(m_screen_cxt, SCREEN_PROPERTY_DISPLAY_COUNT, &count);

	displays = (screen_display_t*)calloc(count, sizeof(screen_display_t));

	screen_get_context_property_pv(m_screen_cxt, SCREEN_PROPERTY_DISPLAYS, (void **)displays);
	screen_get_display_property_iv(displays[0], SCREEN_PROPERTY_SIZE, size);

	free(displays);

 size[0] contains screen width, size[1] contains screen height

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Display Width and Height

[ Edited ]

Try:

 

bb::device:: DisplayManager displayManager;
bb::device:: Display& display = displayManager.getDisplay(displayManager.primaryDisplayId());
QSize size = display.pixelSize();

Stuart

Please use plain text.
Developer
soaman
Posts: 848
Registered: ‎03-03-2011
My Device: Z10

Re: Display Width and Height

I can't find DisplayManager in beta 2 :-(
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Please use plain text.
Developer
soaman
Posts: 848
Registered: ‎03-03-2011
My Device: Z10

Re: Display Width and Height

[ Edited ]

If I use:

 

bb::device::Display display;

 

then I get:

 

C:\BB_DEV\Native\Workspaces\BB10_WS\myTazks\arm/../src/app.cpp:6: undefined reference to `bb::device::Display::Display(QObject*)' 

C:\BB_DEV\Native\Workspaces\BB10_WS\myTazks\arm/../src/app.cpp:25: undefined reference to `bb::device::Display::~Display()'

 

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Please use plain text.
Developer
soaman
Posts: 848
Registered: ‎03-03-2011
My Device: Z10

Re: Display Width and Height

Solution:
in .pro file add LIBS += -lbbdevice
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Please use plain text.
Developer
babcow
Posts: 28
Registered: ‎06-25-2009
My Device: 9930

Re: Display Width and Height

    DisplayInfo display;
    m_nScreenWidth = display.pixelSize().width();
    m_nScreenHeight = display.pixelSize().height();

Please use plain text.