2013-07-09 2 views
0

ImageView를 컨테이너에 추가하려고하는데 화면에 나타나지 않습니다. 컨테이너가 QML로 생성되었지만 이미지를 .CPP 파일에 추가하려고합니다.BlackBerry 10 - 컨테이너에 ImageView 추가

ApplicationUI.cpp :

ApplicationUI::ApplicationUI(bb::cascades::Application *app) 
    : QObject(app) 
    { 
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this); 

AbstractPane *root = qml->createRootObject<AbstractPane>(); 

ImageView* imageView1 = new ImageView(); 
imageView1->setImage(Image("asset:///icon.png")); 

Page *page = qml->createRootObject<Page>(); 
Container *_mRootContainer = page->findChild<Container*>("rootContainer"); 

_mRootContainer->add(imageView1); 
app->setScene(root); 

} 

main.xml에 : 사전에

import bb.cascades 1.0 


Page { 
    Container { 
     objectName: "rootContainer" 
     Label { 
      text: "First page" 
     } 
    } 
} 

감사합니다, 당신이 만들 다음 .CPP 파일에 이미지 컨테이너를 만들 수 있습니다

답변

0

)/모든 이미지를 컨테이너에 추가하십시오. 예 : DockLayout을 사용하여 서로의 이미지를 ontop하고 부모 컨테이너 내에서 가운데에 배치합니다.

//Create the images container and center it within parent container 

    Container *imageContainer = new Container(); 
    imageContainer->setLayout(new DockLayout()); 
    imageContainer->setHorizontalAlignment(HorizontalAlignment::Center); 

//Create the image (add the image file into asset folder) 

    ImageView* imageView1 = ImageView::create("asset:///icon.png"); 

//Align/center image horizontally and vertically within parent container 

    imageView1->setHorizontalAlignment(HorizontalAlignment::Center); 
    imageView1->setVerticalAlignment(VerticalAlignment::Center); 

//Add images to image container 

    imageContainer->add(imageView1);