Multiple items qml



  • hello,

    i've created a qml file named FileBrowser.qml which is an Item.
    in main.qml i created 4 FileBrowser items, but when I do something in a FileBrowser the rest are updating also.

    main.qml
    @
    Rectangle
    {
    id: main
    width: 1248
    height: 1024
    FileBrowser
    {
    id:fileBrowser1
    width:624
    height: 512
    }
    FileBrowser
    {
    id:fileBrowser2
    x:parent.width/2+1
    width:main.width/2
    height: main.height/2
    }
    FileBrowser
    {
    id:fileBrowser3
    x:parent.width/2+1
    y:parent.height/2+1
    width:main.width/2
    height: main.height/2
    }
    FileBrowser
    {
    id:fileBrowser4
    y:parent.height/2+1
    width:main.width/2
    height: main.height/2
    }
    }
    @

    what can i do so each filebrowser could be independent?


  • Moderators

    Please define "when I do something".

    Normally, those 4 instances should be totally independent.



  • for example when i open a folder, all filebrowsers open the same folder.

    the filebrowser uses 2 abstract list models.
    so....when i fill the main.qml with tons of filebrowsers...they shold be dynamicly created and independent of one another.
    how can i create a qml item dynamicly?

    filebrowser.qml is something like
    @
    Item
    {
    Component:myDelegate
    {
    //items of the first list
    }
    }

    Item
    {
    Component:otherDelegate
    {
    //items of the secondlist
    }
    }

    ListView
    {
    delegate:mydelegate
    model:mymodel
    }

    ListView
    {
    delegate:otherdelegate
    model:othermodel
    }
    @


  • Moderators

    I still don't know how you open a folder and in what way you are populating the lists. Maybe you are using a Singleton for that? Or you are, by mistake, opening the same path on all browsers?



  • the list are populated like this
    @
    QList<QFileInfo> m_list;
    m_list<<m_dir.entryInfoList(); //or any path
    @

    i don't think a singleton could work for what i'm trying to do.
    indeed, all browsers are opening the same path.


  • Moderators

    Man, it's sure are hard to get relevant information from you.

    Where does this "m_dir" come from? How do you set it? Where? If you set it once in your C++ code, and then don't modify that path anywhere in QML (after the objects are instantiated), then that path will be the same for all instances.


Log in to reply
 

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