Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. PathView Using QAbstractListModel Determines Count Late

PathView Using QAbstractListModel Determines Count Late

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Hornsj2
    wrote on last edited by
    #1

    I'm trying to use a ListModel defined in C++ to supply data to a PathView element.

    I'm using the tutorial below as an example, because I want to create a page control component:

    "Example I'm following":http://wiki.forum.nokia.com/index.php/How_to_create_a_Page_Control_component_in_QML

    @ path: Path {
    startX: - pageControl.width * listModel.count / 2 + pageControl.width / 2
    startY: pageControl.height / 2
    PathLine {
    x: pageControl.width * listModel.count / 2 + pageControl.width / 2
    y: pageControl.height / 2
    }
    }@

    The pathview element is created correctly, with the exception that it is placed incorrectly due to what I believe is a race-condition between initialization of the listModel and the position of the path.

    The problem is with the above section of code. It seems that listModel.count gets updated AFTER the PathView.path is defined, which causes undefined behavior (QML claims a NAN is being used to place the path).

    This happens even though I'm creating the QAbstractListModel, then assigning it to the root context of the view, THEN i'm setting the main QML file.

    I was able to get around the problem by creating a property called pathViewSize and explicitly setting it to the proper count value after adding page elements but this is a hack and I don't like it. Suggestions?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tedmiddleton
      wrote on last edited by
      #2

      I'm pretty sure that I'm running into exactly the same problem:

      "http://qt-project.org/forums/viewthread/26441/":http://qt-project.org/forums/viewthread/26441/
      "http://stackoverflow.com/questions/15753419/qt-qml-data-model-doesnt-seem-to-work-with-c":http://stackoverflow.com/questions/15753419/qt-qml-data-model-doesnt-seem-to-work-with-c

      I'm wondering if the Qt bug tracker already lists this? With the source available, I'm tempted to dive into the declarative engine and fix it myself, but without more knowledge of the Qt code base, it would probably take me days to do it.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tedmiddleton
        wrote on last edited by
        #3

        Not sure if you're still interested, but I had a conversation with a couple of former Trolltech employees on IRC last night. They helped me with this and I've posted the answer to my StackOverflow question.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved