Home
Developer Resources
QNX RTOS v4
QNX RTOS v4 Knowledge Base

QNX RTOS v4 Knowledge Base

Foundry27
Foundry27
QNX RTOS v4 project
Resources

QNX RTOS v4 Knowledge Base

Title Getting the selected item from a PtTree
Ref. No. QNX.000009868
Category(ies) Development
Issue We only allow the user to select a single item from a PtTree widget. In order get selected item, do we use PtTreeSelectedItems()?
Can we get more info about this function?

Solution The following function returns the selected item or a NULL, if none is selected. It's only safe with single selection mode. You can expect a crash is more than one item is selected:
x09PtTreeItem_t *selected_item (PtWidget_t *tree){
x09x09PtTreeItem_t *result;
x09x09PtTreeSelectedItems(tree, &result);
x09x09return result;
x09}
The PtTreeSelectedItems() returns the address of the buffer. It is either the buffer that you passed to the function or a buffer that the function allocated for you.

If multiple items were selected, all items are put in the 'buffer'. If you pass your own buffer, it is your responsibility to make sure that the buffer is large enough. You find out the number of selected items by getting the Pt_ARG_LIST_SEL_COUNT resource.