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
SumiGhosh
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Getting flickMode of Listview in cpp

Hi all,

 

I have a horizontal listview with flickmode. Did any one know how to catch the event flickmode in cpp?

Please use plain text.
Developer
SumiGhosh
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Getting flickMode of Listview in cpp

i am pasting my qml and cpp code.

 

QML :CustomListView

Container {
    
    ListView {
        property variant layoutFrame
        property variant visibleItemData 
       
        id: horizontal_listview
        objectName: "horizontal_listview"
        dataModel: XmlDataModel { source:"datamodel_full.xml" }
        layout: StackListLayout { orientation: LayoutOrientation.LeftToRight } // Works fine with any orientation
        snapMode: SnapMode.LeadingEdge
        flickMode: FlickMode.SingleItem
        scrollIndicatorMode: ScrollIndicatorMode.None
        attachedObjects: [
            LayoutUpdateHandler { onLayoutFrameChanged: horizontal_listview.layoutFrame = layoutFrame }//, 
           // ListScrollStateHandler { onFirstVisibleItemChanged: horizontal_listview.visibleItemData = dataModel.data(firstVisibleItem) }
        ]
        listItemComponents: ListItemComponent {
            type: "__carouselitem" 
            
            Container {
                preferredHeight: ListItem.view.layoutFrame.height
                preferredWidth: ListItem.view.layoutFrame.width
                
                layout: DockLayout { }
                ImageView {
                    id:bgimg
                    imageSource: ListItemData.imgsrc
                }
            } // end Container
        } // end ListItemComponent
        
        function itemType(data, indexPath) {
            var type = horizontal_listview.dataModel.itemType(indexPath);
            return "__carouselitem";
        }
        
    }
}

 

 

My Cpp:

CustomListView::CustomListView() {
	// TODO Auto-generated constructor stub
	 QmlDocument *qml = QmlDocument::create("asset:///CustomListView.qml");
	 custom_listview_container = qml->createRootObject<Container>();
	 horizontal_listview = new ListView();
	 horizontal_listview = custom_listview_container->findChild<ListView*>("horizontal_listview");

	 connect(horizontal_listview,SIGNAL(flickModeChanged(bb::cascades::FlickMode::Type flickMode)),this,SLOT(onClickListItem(bb::cascades::FlickMode::Type flickMode)));

}

void CustomListView::onClickListItem(bb::cascades::FlickMode::Type flickMode){
	qDebug()<<" onClickListItem ";
}

 But i am not able to connect the flickmode of listview. Please let me know what i am doing wrong. 

Please use plain text.
Developer
SumiGhosh
Posts: 435
Registered: ‎09-20-2011
My Device: Z10 LE, Playbook, DevAlpha C, 9900, 9380
My Carrier: Vodafone

Re: Getting flickMode of Listview in cpp

 mistake. Got it. 

Please use plain text.