J
J
JuniorHelp2020-10-19 14:36:16
Qt
JuniorHelp, 2020-10-19 14:36:16

How to save data to QString from qlineedit on button click?

Maine has this code

QApplication app(argc, argv);
    QWidget wgt;

QString str;

QLineEdit* line_edit_1  = new QLineEdit;
QPushButton* push_but = new QPushButton;

QHBoxLayout* phbxLayout = new QHBoxLayout;
     phbxLayout->setContentsMargins(10, 10, 10, 10);
     phbxLayout->setSpacing(20);

     phbxLayout->addWidget(line_edit_1);
     wgt.setLayout(phbxLayout);
     wgt.show();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ighor July, 2020-10-19
@JuniorHelp

You need to create your own slot in which to connect the click, and get the text from the button there.

J
Jacob E, 2020-10-20
@Zifix

Read any book on Qt. I understand that it seems like a long time, and there are a lot of beeches, but you will save yourself a lot of time and will not get stuck on such elementary questions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question