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. Signal emit Issue - Listview is not showing full list
QtWS25 Last Chance

Signal emit Issue - Listview is not showing full list

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
listviewbindcppsignals emit
4 Posts 2 Posters 2.2k 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.
  • M Offline
    M Offline
    Mathan M
    wrote on 14 Oct 2016, 15:32 last edited by Mathan M
    #1

    Hi,

    I am binding an ListView with values passing from the cpp, Pls refer the code.

    Issue: Listview displays only one row, mean first value, The rest of the rows are not appeared.

    Checked:
    I created an ListModel/ListElement in main.qml as test and bind with ListView, Now the Listview just working fine, display all values

    I suspect after the signal emit, the error occurs.

    Code snippet:

    main.qml

    ListView {
    id: idListView
    anchors {
    left: parent.left
    leftMargin: 10 * scaleFactor
    right: parent.right
    rightMargin: 10 * scaleFactor
    top: rectangleToolBar.bottom
    topMargin: 10 * scaleFactor
    bottom: rectangleStatusBar.top
    bottomMargin: 10 * scaleFactor
    }
    // model: objHomeController.detailsModel // Display only one row
    //model: idListmodel //Working fine
    delegate: comsearchDelegate
    spacing: 10 * scaleFactor
    clip: true
    
    highlight: Rectangle {
    color: 'grey'
    Text {
    anchors.centerIn: parent
    color: 'white'
    }
    }
    focus: true
    }
    
    
    Component {
    
    id: comsearchDelegate
    Row {
    spacing: 10 * scaleFactor
    
    Column {
    Layout.alignment: Qt.AlignTop
    
    Text { text: title; font { pixelSize: 14 * scaleFactor; bold: true } }
    Text { text: description; font { pixelSize: 14 * scaleFactor; bold: true } }
    
    }
    }
    }
    
    ListModel
    {
    
    id: idListModel
    ListElement{
    title : "sdfsdf";
    description:"sdfsdfs";
    
    }
    ListElement{
    title : "sdfsdf";
    description:"sdfsdfs";
    
    }
    ListElement{
    title : "sdfsdf";
    description:"sdfsdfs";
    
    }
    ListElement{
    title : "sdfsdf";
    description:"sdfsdfs";
    
    }
    }
    

    HomeController.h

    Q_PROPERTY(Model* detailsModel READ get_detailsModel WRITE set_detailsModel NOTIFY detailsModelChanged )
    

    HomeController.cpp

    void HomeController::set_detailsModel(Model* value)
    {
    m_detailsModel = value;
    
    //value has correct values - checked.
    emit detailsModelChanged(value);
    }
    

    Thanks in advacne

    R 1 Reply Last reply 14 Oct 2016, 16:56
    0
    • M Mathan M
      14 Oct 2016, 15:32

      Hi,

      I am binding an ListView with values passing from the cpp, Pls refer the code.

      Issue: Listview displays only one row, mean first value, The rest of the rows are not appeared.

      Checked:
      I created an ListModel/ListElement in main.qml as test and bind with ListView, Now the Listview just working fine, display all values

      I suspect after the signal emit, the error occurs.

      Code snippet:

      main.qml

      ListView {
      id: idListView
      anchors {
      left: parent.left
      leftMargin: 10 * scaleFactor
      right: parent.right
      rightMargin: 10 * scaleFactor
      top: rectangleToolBar.bottom
      topMargin: 10 * scaleFactor
      bottom: rectangleStatusBar.top
      bottomMargin: 10 * scaleFactor
      }
      // model: objHomeController.detailsModel // Display only one row
      //model: idListmodel //Working fine
      delegate: comsearchDelegate
      spacing: 10 * scaleFactor
      clip: true
      
      highlight: Rectangle {
      color: 'grey'
      Text {
      anchors.centerIn: parent
      color: 'white'
      }
      }
      focus: true
      }
      
      
      Component {
      
      id: comsearchDelegate
      Row {
      spacing: 10 * scaleFactor
      
      Column {
      Layout.alignment: Qt.AlignTop
      
      Text { text: title; font { pixelSize: 14 * scaleFactor; bold: true } }
      Text { text: description; font { pixelSize: 14 * scaleFactor; bold: true } }
      
      }
      }
      }
      
      ListModel
      {
      
      id: idListModel
      ListElement{
      title : "sdfsdf";
      description:"sdfsdfs";
      
      }
      ListElement{
      title : "sdfsdf";
      description:"sdfsdfs";
      
      }
      ListElement{
      title : "sdfsdf";
      description:"sdfsdfs";
      
      }
      ListElement{
      title : "sdfsdf";
      description:"sdfsdfs";
      
      }
      }
      

      HomeController.h

      Q_PROPERTY(Model* detailsModel READ get_detailsModel WRITE set_detailsModel NOTIFY detailsModelChanged )
      

      HomeController.cpp

      void HomeController::set_detailsModel(Model* value)
      {
      m_detailsModel = value;
      
      //value has correct values - checked.
      emit detailsModelChanged(value);
      }
      

      Thanks in advacne

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 14 Oct 2016, 16:56 last edited by
      #2

      @Mathan-M
      when it only displays 1 row the model is correctly applied to the view right?
      So the model implementation is the interesting part then.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Mathan M
        wrote on 15 Oct 2016, 12:22 last edited by
        #3

        I understood there might be a problem in applying the model.

        Do we have any link/tutorials to follow or how to bind the value from CPP to qml.

        MM

        R 1 Reply Last reply 15 Oct 2016, 16:06
        0
        • M Mathan M
          15 Oct 2016, 12:22

          I understood there might be a problem in applying the model.

          Do we have any link/tutorials to follow or how to bind the value from CPP to qml.

          MM

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 15 Oct 2016, 16:06 last edited by
          #4

          @Mathan-M
          as i said when it displays a row, the model is correctly applied, so there must be something wrong with your model implementation.

          @Mathan-M said in Signal emit Issue - Listview is not showing full list:

          Do we have any link/tutorials to follow or how to bind the value from CPP to qml.

          Here you go.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          4/4

          15 Oct 2016, 16:06

          • Login

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