I have one window of Qt that shows the clients name in a QListWidget. When I double-click on it, a new window come up and has to show the line edit with the name on it and a button for saving changes.

I made the new window and the line edit in that window but I do not know how to pass de QString "name" into that window from the main window

1 Answers

Nikos C. On

Just call setText() on the new window's line edit after you create the window. I assume you are using the QListWidget::itemDoubleClicked() signal to detect the double click. That signal passes a QListWidgetItem pointer as parameter. So if you connected that signal to a slot that takes a QListWidgetItem* parameter, then you get the text of the double-clicked entry through the QListWidgetItem::text() function:

void mySlot(QListWidgetItem* item)
    // Create the new window and the line edit.
    // ...


    // Now show the new window.