Solved How obtain from input array (QLineEdit)
-
I find it difficult to pass the value from QLineEdit array, here is my snipped code, or there are alternative paths to achieve this goal?
void Thisclass::fct() { QMultiMap<QString,int> bbuMapped; bbuMapped.insert("bbu3",0); bbuMapped.insert("bbu2",1); QLineEdit *txt_rxgain[bbuMapped.size()]; QLineEdit .. QLineEdit .. for (int i = 0; i < bbusCount; i++) { txt_rxgain[i] = new QLineEdit; .. = new QLineEdit; .. = new QLineEdit; } connect(btn_loadconf[i] , &QPushButton::clicked, [this] { emit funcSaveForm(); }); } void Thisclass::funcSaveForm() { // here ,how can i obtain value from input }
-
@rifky said in How obtain from input array (QLineEdit):
or there are alternative paths to achieve this goal?
Which goal? Please explain what you want to achieve in an understandable way.
-
@jsulm said in How obtain from input array (QLineEdit):
@rifky said in How obtain from input array (QLineEdit):
or there are alternative paths to achieve this goal?
Which goal? Please explain what you want to achieve in an understandable way.
pasing value from QLineEdit after click button
-
@rifky said in How obtain from input array (QLineEdit):
QLineEdit *txt_rxgain[bbuMapped.size()];
You have to declare *txt_rxgain as class member variable to be able to access it outside of fct().
Then you can easily access it in funcSaveForm().
This is basic C++. -
solved :
QLineEdit * raw_rxgain = txt_rxgain[i]; connect(btn_loadconf[i] , &QPushButton::clicked, [this] { QJsonObject tempObjValue; tempObjValue.insert("rxgain",raw_rxgain->text().toInt()); emit funcSaveForm(tempObjValue); }); } void Thisclass::funcSaveForm(QJsonObject object) { qDebug()<<"clicked funcSaveForm"<< object; }
-
@rifky
Up to you, but (if this isconnect()
ed withDirectConnection
) wouldn't it be faster to go:void Thisclass::funcSaveForm(const QJsonObject &object)
?