View Full Version : Get current line edit text and return to some class
Cyrebo
30th April 2013, 19:20
Hi, I want to get the current text from line edit and return its containing text to another class without using a signal/slot button. This process needs to happen only once. I can't think of anyway to do it right now.
Thanks in advance.
amleto
30th April 2013, 19:50
Hi, I want to get the current text from line edit and return its containing text to another class without using a signal/slot button. This process needs to happen only once. I can't think of anyway to do it right now.
void
get_the_current_text_from_lineedit_and_return_cont aining_text_to_another_class_without_using_a_signa l_or_slot(QLineEdit* lineedit, AnotherClass* otherClass)
{
QString text = lineedit->text();
otherClass->DoSomething(text);
}
Thanks in advance.
You're welcome.
Cyrebo
30th April 2013, 20:12
void
get_the_current_text_from_lineedit_and_return_cont aining_text_to_another_class_without_using_a_signa l_or_slot(QLineEdit* lineedit, AnotherClass* otherClass)
{
QString text = lineedit->text();
otherClass->DoSomething(text);
}
You're welcome.
From the above it looks like you are getting the text and applying changes in one method. I need to use the line edit text in the other classes method.
wysota
1st May 2013, 11:18
From the above it looks like you are getting the text and applying changes in one method. I need to use the line edit text in the other classes method.
void get_the_current_text_from_lineedit_and_use_it_in_t he_other_classes_method(QLineEdit *lineedit, AnotherClass *otherClass) {
QString text = lineedit->text();
otherClass->setTextThatCanBeUsedElsewhere(text);
}
void AnotherClass::setTextThatCanBeUsedElsewhere(const QString &txt) { m_textThatCanBeUsedElsewhere = txt; }
void AnotherClass::doSomethingWithTextSetWithSetTextTha tCanBeUsedElsewhere() {
doSomethingWith(m_textThatCanBeUsedElsewhere);
}
You're welcome.
By the way, how is this problem related to Qt?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.