Qli neEdit returnPressed.connect

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
codebanger
Registered Member
Posts: 1
Joined: Mon Jul 06, 2015 2:58 pm

Qli neEdit returnPressed.connect

Post by codebanger » Sun Jul 26, 2015 11:27 pm

I have a subroutine to return text. I would like it to return when return is pressed but it won't work. Here is the sub

function inptxt(){
    var dialog = new QDialog(this);
    dialog.title = "Input text";
    var fbox = new QFormLayout;
    var stxt = new QLineEdit; 
    stxt.returnPressed.connect(function() {  //doesn't work
        return stxt.text;
    });
    fbox.addRow(stxt);
    dialog.setLayout(fbox);
    if (dialog.exec()) {
    }
    return stxt.text;
}
Does anyone know why the connect function doesn't work?
Thanks very much in advance

User avatar
andrew
Site Admin
Posts: 9061
Joined: Fri Mar 30, 2007 6:07 am

Re: Qli neEdit returnPressed.connect

Post by andrew » Mon Jul 27, 2015 9:57 am

The return on line 7 returns from your local function defined on lines 6-8.

If you wish to close the dialog when return is pressed in that line edit, you can connect returnPressed to the dialogs close slot:
stxt.returnPressed.connect(dialog, "close");
Your inpttxt function will still return stxt.text.

Post Reply

Return to “QCAD 'How Do I' Questions”