Signal emit Issue - Listview is not showing full list



  • 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


  • Moderators

    @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.



  • 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


  • Moderators

    @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.


Log in to reply
 

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