Results 1 to 3 of 3

Thread: How to append one more item to VisualItemModel?

  1. #1
    Join Date
    Nov 2010
    Posts
    8
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default How to append one more item to VisualItemModel?

    Hello,
    I have defined a list view which has to show some Clocks that have their onw shape. So, I need not define any delegate to the list view. Hence, I have used VisualItemModel for the list view.
    Now, I want to append one more item to the model in some other qml file.
    How can I do that? I have tried below things but getting syntax errors.

    I have defined the list view and model in this way:
    ************************************************** *
    // Create the world clock view
    VisualItemModel {
    id: clocksModel
    Clock { city: "New York, USA"; shift: -4; anchors.horizontalCenter: window.horizontalCenter }
    Clock { city: "Mumbai, INDIA"; shift: 5.5; anchors.horizontalCenter: window.horizontalCenter }
    Clock { city: "Tokyo, JAPAN"; shift: 9; anchors.horizontalCenter: window.horizontalCenter }
    Clock { city: "Karachi, PAKISTAN"; shift: 6.5; anchors.horizontalCenter: window.horizontalCenter }
    Clock { city: "Sydney, AUSTRALIA"; shift: 18; anchors.horizontalCenter: window.horizontalCenter }
    Clock { city: "Boston, USA"; shift: -3.5; anchors.horizontalCenter: window.horizontalCenter }
    }

    ListView {
    id: worldClock
    anchors.top: titleBar.bottom
    anchors.left: window.left
    anchors.right: window.right
    anchors.bottom: toolbar.top
    clip: true
    height: parent.height
    visible: true
    model : clocksModel
    transform: Rotation {
    id: worldClockViewRotation; origin.x: parent.width; origin.y: parent.height
    axis.x: 0; axis.y: 1; axis.z: 0
    }
    }
    ************************************************** ****

    Now, in another qml file, depending some use action, I want to append one more "Clock" item to the model in this way:
    ************************************************** ******
    MouseArea {
    anchors.fill: parent
    onClicked: {
    var city = cityTextEdit.text + "," + countryTextEdit.text;

    clocksModel.append(Clock {
    city: city; shift: gmtTextEdit.text;
    anchors.horizontalCenter: window.horizontalCenter
    })
    // Get the details entered by user
    readForm()
    // Switch to main view
    window.state = "worldClockState"
    addCityEditor.state = "Hide"
    }
    }
    ************************************************** *******

    Its showing syntax error "Expected: )" at the brace '{' that is followed after 'Clock'.

    Please let me kniw how can I acheive my use case here.

    Thanks
    Chiru

  2. #2
    Join Date
    Dec 2010
    Posts
    6

    Default Re: How to append one more item to VisualItemModel?

    Did you find a solution to this problem? I am trying to do a similar thing.

    Cheers

    Matt

  3. #3
    Join Date
    May 2010
    Posts
    61
    Thanks
    2
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to append one more item to VisualItemModel?

    Hi guys,

    I would also be interested in this.
    Did you find any solution?

    thanks,
    wladek
    One second is long, everything longer than two seconds is definitely too long.

Similar Threads

  1. Append to a XML Document
    By Goldmmbr in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2009, 15:03
  2. Cannot append to QFile using QIODevice::Append
    By philwinder in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2008, 09:09
  3. QVector - Append
    By krishbhala in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2007, 10:50
  4. QTextEdit::append help
    By tho97 in forum Qt Programming
    Replies: 1
    Last Post: 29th November 2007, 07:10
  5. QStandardItemModel: copy and append
    By davisjamesf in forum Newbie
    Replies: 1
    Last Post: 19th September 2007, 16:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.