Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. Independent Developers
  4. How to transfer data between tabs in a tabview
Forum Updated to NodeBB v4.3 + New Features

How to transfer data between tabs in a tabview

Scheduled Pinned Locked Moved Solved Independent Developers
3 Posts 2 Posters 898 Views 1 Watching
  • 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.
  • NIvil WilsonN Offline
    NIvil WilsonN Offline
    NIvil Wilson
    wrote on last edited by NIvil Wilson
    #1

    when i try to cler or load data to textfields from one tab to another it shows txt_name does not exist error

    Pls help```
    code_text
    import QtQuick 2.12
    import QtQuick.Controls 1.4
    import QtQuick.Controls 2.12
    import SuppliersSqlModel 0.1
    import "controls" as C
    import QtQuick.Layouts 1.12

    Item {
    id:ms

    GridLayout{
    anchors.fill: parent

    rows: 3
    columns: 11
    

    RowLayout{

    Layout.row: 1
    Layout.column: 9
    Layout.topMargin: 5
    Layout.rightMargin: 5
    layoutDirection:Qt.LeftToRight
    width: 300
    height:33
    
    Label{
    
        id:lbl_search
    
        anchors.topMargin: 11
        text: "Search"
    
    }
    
    C.NTextField{
    
        id:txt_search
        width: 200
    
       onAccepted: {
            suppliers.search(txt_search.text);
        }
    }
    

    }

        TabView {
            id:tab_view
            Layout.row: 2
            Layout.column: 0
            Layout.columnSpan: 7
            Layout.leftMargin: 20
            Layout.bottomMargin: 10
            Layout.preferredWidth: 900
           Layout.fillHeight: true
    
    
    
    
    
    
        Tab {
            title: "Primary Details"
            active: true
    
            id: primary_details
            Item {
                id: item_1
    
                GridLayout {
    
                    rows: 5
                    columns: 3
    
                    Label {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 1
                        Layout.column: 1
                        text: "Is a GST registred supplier ?"
                    }
    
                    CheckBox {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 1
                        Layout.column: 2
                        id: chkbox_reg
                        text: qsTr("check if Have GST resistration")
                        checked: true
                    }
    
                    Label {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 2
                        Layout.column: 1
                        text: "GSTIN"
                    }
    
                    C.NTextField {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 2
                        Layout.column: 2
                        id: txt_gstin
    
                        width: 200
    
                        placeholderText: qsTr("GSTIN")
                    }
    
                    Label {
                        Layout.leftMargin: 20
    
                        Layout.row: 3
                        Layout.column: 1
                        text: "PAN"
                    }
    
                    C.NTextField {
                        id: txt_pan
                        Layout.leftMargin: 20
    
                        Layout.row: 3
                        Layout.column: 2
                        width: 200
    
                        placeholderText: qsTr("PAN")
                    }
    
                    Label {
                        Layout.leftMargin: 20
    
                        Layout.row: 4
                        Layout.column: 1
                        text: "name of the supplier"
                    }
    
                    C.NTextField {
                        id: txt_name
                        Layout.leftMargin: 20
    
                        Layout.row: 4
                        Layout.column: 2
                        width: 200
                        placeholderText: qsTr("name")
                    }
    
                    Label {
                        Layout.leftMargin: 20
    
                        Layout.row: 5
                        Layout.column: 1
                        text: "mobile number"
                    }
    
                    C.NTextField {
                        id: txt_mob
                        Layout.leftMargin: 20
    
                        Layout.row: 5
                        Layout.column: 2
                        width: 200
                        placeholderText: qsTr("mob")
                    }
                }
    
            }
    
        }
        Tab {
            title: "Other Details"
            active: true
            Item {
                id: other_details
    
                GridLayout {
                    rows: 3
                    columns: 3
    
                    Label {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 1
                        Layout.column: 1
                        text: "Address of the Supplier"
                    }
    
                    TextArea {
                        id: txt_area_address
                        Layout.topMargin: 20
                        Layout.row: 1
                        Layout.column: 2
                        width: 200
                        height: 79
                        placeholderText: qsTr("Address")
                    }
    
                    Label {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 2
                        Layout.column: 1
                        text: "Phone Number"
                    }
    
                    C.NTextField {
                        id: txt_phone
                        Layout.topMargin: 20
                        Layout.row: 2
                        Layout.column: 2
                        width: 200
                        placeholderText: qsTr("Phone")
                    }
    
                    Label {
                        Layout.leftMargin: 20
                        Layout.topMargin: 20
                        Layout.row: 3
                        Layout.column: 1
                        text: "email"
                    }
    
                    C.NTextField {
                        id: txt_email
                        Layout.topMargin: 20
                        Layout.row: 3
                        Layout.column: 2
                        width: 200
                        placeholderText: qsTr("email")
                    }
                }
    
            }
    
        }
        Tab {
            title: "Suppliers List"
            active: true
    
            TableView {
                id:tbl_view
                anchors.fill: parent
    
    
    
                TableViewColumn {
                    role: "id"
                    title: "ID"
                    width: 100
                }
                TableViewColumn {
                    role: "name"
                    title: "Name"
                    width: 200
                }
                TableViewColumn {
                    role: "gstin"
                    title: "GSTIN"
                    width: 200
                }
                TableViewColumn {
                    role: "pan"
                    title: "PAN"
                    width: 200
                }
                TableViewColumn {
                    role: "mob"
                    title: "Mob"
                    width: 200
                }
                TableViewColumn {
                    role: "address"
                    title: "Address"
                    width: 300
    
                }
                TableViewColumn {
                    role: "email"
                    title: "Email"
                    width: 200
                }
                TableViewColumn {
                    role: "phone"
                    title: "Phone"
                    width: 200
                }
                model:suppliers
    
                onClicked: {
                    if(tbl_view.currentRow==-1){
                        console.log("no row selected");
                    }else{
                        btn_delete.enabled=true;
                        btn_edit.enabled=true;
                        let c= suppliers.getData(tbl_view.currentRow);
                        console.log("the current row is ",c);
    
    
                    }
                }
    
                onDoubleClicked: {
    
                    clearFields();
                    loadRowDetailsToFields();
                }
            }
    
    
        }
    }
    

    ColumnLayout{
    Layout.row: 2
    Layout.column: 8
    Layout.fillHeight: true;
    Layout.leftMargin: 20
    Layout.topMargin:30

    Item {
    
        GridLayout {
            Layout.fillHeight: true
            Layout.fillWidth: true
            rows: 10
            columns: 2
            Label {
                Layout.row: 1
                text: "Supplier Details :-"
                font.underline: true
                font.italic: true
                font.bold: true
                font.pointSize: 14
            }
            Label {
                Layout.row: 2
                Layout.column: 0
                text: "GST status"
            }
            Label {
                Layout.row: 2
                Layout.column: 1
                text: "Unknown"
            }
    
            Label {
                Layout.row: 3
                Layout.column: 0
                text: "GSTIN"
            }
            Label {
                Layout.row: 3
                Layout.column: 1
                text: "Unknown"
            }
    
            Label {
                Layout.row: 4
                Layout.column: 0
                text: "PAN"
            }
            Label {
                Layout.row: 4
                Layout.column: 1
                text: "Unknown"
            }
    
            Label {
                Layout.row: 5
                Layout.column: 0
                text: "Name"
            }
            Label {
                Layout.row: 5
                Layout.column: 1
                text: "Unknown"
            }
    
            Label {
                Layout.row: 6
                Layout.column: 0
                text: "Mobile"
            }
            Label {
                Layout.row: 6
                Layout.column: 1
                text: "Unknown"
            }
        }
    }
    

    }

    //Buttons
    RowLayout{
    Layout.row: 3
    Layout.bottomMargin: 22
    Layout.topMargin: 11
    Layout.leftMargin: 20
    Layout.rightMargin: 20

    C.NButton {
    
        id: btn_save
    
        text: qsTr("Create")
        onClicked: {
            saveOrUpdate();
        }
    }
    
    
    
    C.NButton {
    
        id: btn_delete
    
        enabled: false;
        text: qsTr("delete")
        onClicked:{
            let id= suppliers.getData(tbl_view.currentRow);
            let status= suppliers.deleteSupplier(id);
            console.log("deleted");
        }
    
    }
    
    C.NButton {
    
        id: btn_edit
        enabled: false;
        onClicked: {
    
    loadRowDetailsToFields();
    
        }
    
        text: qsTr("edit")
    }
    

    }

    }

    //MouseArea{
    // anchors.fill: parent;
    // onClicked: {
    // edit_clicked=false;
    // btn_save.text="Create";
    // btn_delete.enabled=false;
    // btn_edit.enabled=false;
    // tbl_view.selection.deselect(tbl_view.currentRow);
    // clearFields();

    // }

    Suppliers{
        id:suppliers
    }
    

    function clearFields(){
    txt_name.clear();
    txt_gstin.clear();
    txt_email.clear();
    txt_phone.clear();

    }

    function loadRowDetailsToFields(){
    edit_clicked=true;
    btn_save.text="update";

    txt_name.text=suppliers.data(suppliers.index(tbl_view.currentRow,1));
    txt_gstin.text=suppliers.data(suppliers.index(tbl_view.currentRow,2));
    txt_pan.text=suppliers.data(suppliers.index(tbl_view.currentRow,3)) ;
    txt_mob.text=suppliers.data(suppliers.index(tbl_view.currentRow,4));
    txt_area_address.text=suppliers.data(suppliers.index(tbl_view.currentRow,5));
    txt_email.text=suppliers.data(suppliers.index(tbl_view.currentRow,6));
    txt_phone.text=suppliers.data(suppliers.index(tbl_view.currentRow,7));
    

    }

    function saveOrUpdate(){

    let reg="false"
    if(chkbox_reg.checkState==Qt.Checked){
        reg="true"
    
    }
    

    if(edit_clicked===false){

    let result=  suppliers.createSupplier(txt_name.text,txt_gstin.text,txt_pan.text,txt_mob.text,reg,txt_area_address.text,txt_email.text,txt_phone.text);
    console.log("create supplier result is =",result);
       clearFields();
    

    }
    if(edit_clicked){

       let id= suppliers.data(suppliers.index(tbl_view.currentRow,0));
       let result=  suppliers.updateSupplier(id,txt_name.text,txt_gstin.text,txt_pan.text,txt_mob.text,reg,txt_area_address.text,txt_email.text,txt_phone.text);
         console.log("update supplier result is =",result);
    

    edit_clicked=false;
    btn_save.text="Create";
    clearFields();
    }

    }

    }

    /##^##
    Designer {
    D{i:0;autoSize:true;height:480;width:640}
    }
    ##^##
    /

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use signals and slots, models, maybe something else.

      You have to give more details about your application if you want more precise answers.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      NIvil WilsonN 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        You can use signals and slots, models, maybe something else.

        You have to give more details about your application if you want more precise answers.

        NIvil WilsonN Offline
        NIvil WilsonN Offline
        NIvil Wilson
        wrote on last edited by
        #3

        @SGaist
        sir i just updated my topic with my code .

        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