Passing Paramater from .cpp file to .qml file



  • Hello everyone...
    I wanna asking you about passing parameter in .qml file from .cpp file.
    I've a function for getting filename in widgetmap . . .
    and then I would like to show map using .qml file.

    @...
    WidgetMap::WidgetMap(QString idofinformation, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::WidgetMap)
    {
    ui->setupUi(this);

    ....
        //I get the filename from database
        //set the filename
        this->filename = this->hasil.result->__ptr[0]->FileName;
        //set the serverfilename
        ftpdownloader->serverfilename = this->filename;
        ...
    

    }

    WidgetMap::~WidgetMap()
    {
    delete ui;
    }

    //back toolbutton
    void WidgetMap::slotToolButtonBack()
    {
    ...
    }

    void WidgetMap::slotShowMap(bool failed)
    {
    // I use qml file by setting the source (detailMap.qml)

    ...
     this->view->setSource(QUrl(QString::fromUtf8(this->applicationdirpath.absolutePath().toUtf8() + "/DetailMap.qml")));
       ...
    

    }@

    and then this is in .qml file :
    @
    ....

    Rectangle
    {
    width: 640
    height: 480

    // Create a flickable to view a large image.
    Flickable
    {
       ...
    
       //I use
        Image
        {
            id: picture
            source: "denah.png"
            asynchronous: true
        }
    
        ...
    

    }
    @

    I use filename to get it from database, then I want to set the filename in .qml file to show it using qml. How can I passing the filename in .qml file?
    thx b4.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.