How to increment QLineEdit name to access value?

时间:2016-02-12 20:27:22

标签: python variables pyqt increment qlineedit

This seems like a really simple question, but has me stumped. I've got a UI that has multiple QLineEdits for names, start, and end times. For example:

clipName1, clipStart1, clipEnd1 clipName2, clipStart2, clipEnd2 clipName2, clipStart3, clipEnd3

These are not dynamically built on the fly. They are static. I wish to access the values from these by going through a loop. I am not sure how I can append an integer onto the variable name and still be able to access the value. I've tried this which I know doesn't work:

$('#ss').live('click', function () {
    $("#main_login").html("<center>waiting plaese . . . .</center>");
    var arr = [];
    $(".myInputs").each(function() {
        arr.push($(this).val());
    });

    $.ajax({
        type: 'POST',
        url: 'process.php',
        data: { "myInputs[]" : arr },
        success: function (data) {
            $('#main_login').html(data)
        }
    });
});

1 个答案:

答案 0 :(得分:0)

Answer provided by ekhumoro in comments above:

clipName = getattr(self, 'clipName%d' % i).text()