I work on Qt and I don't understand how to link QPushButton
and QLineEdit
. I did this for the QPushButton
:
QHBoxLayout accountlayout;
QLabel accountlabel("AccountServer");
QLineEdit accountlineedit;
QPushButton accountbuttonselect("Select");
QPushButton accountbuttonlaunch("Launch");
QPushButton accountbuttonstop("Stop");
QString accountfile;
accountlayout.addWidget(&accountlabel);
accountlayout.addWidget(&accountlineedit);
accountlayout.addWidget(&accountbuttonselect);
accountlayout.addWidget(&accountbuttonlaunch);
accountlayout.addWidget(&accountbuttonstop);
QObject::connect(&accountbuttonselect,
&QPushButton::clicked,
[&window, &accountfile] {
accountfile = QFileDialog::getOpenFileName(
window,
QObject::tr("Sélectionner un exécutable ..."),
"C:/", QObject::tr("Exécutable (*.exe)"));
});
layout.addLayout(&accountlayout);
I open QFileDialog
to search for an executable file and I want to set the QLineEdit
to show the directory specified. How can I do that?