basic question: getting value from qwidget and use it in mainapplication
hi :D
Please I am new in qt4 world:confused: My application is composed of a mainapplication window and a qwidget.
I want get the value qstring from the lineedit.text(); in the qwidget to use it in the main window. so Howto?:crying:
Re: basic question: getting value from qwidget and use it in mainapplication
Re: basic question: getting value from qwidget and use it in mainapplication
Hi
The tutorial presents QT3 but i need QT4 solution. I need just how to get information (qstrings or int) from a QDialog or Qwidget to use them in the main window.
Re: basic question: getting value from qwidget and use it in mainapplication
there are lots of oss available in the links section, or the Qt Software section. go through those.
It's just a basic question of accessing a member variable's methods
What will you do in this situation
Code:
// Represents whatever widget
class ClassIAmInterestedIn {
public:
void tryToAccessMe();
}
// Represents Container Holding the widget ( Maybe a Dialog )
class IhaveObjectYouAreInterestedIn{
private:
ClassIAmInterestedIn objectOfThatClass;
};
// You are working in this class
class IAmHere {
public:
void someMethod(){
IhaveObjectYouAreInterestedIn obj;
obj.doSomeThingInteresting();
// Now there is achange in IhaveObjectYouAreInterestedIn::objectOfThatClass;
// and U will have to access objectOfThatClass::tryToAccessMe()
// Fig out how to access that
}
};
Re: basic question: getting value from qwidget and use it in mainapplication
hi,
Do you want get data from QLineEdit box ?
the follwing function should return what ever lineedit box contains
QString displayText() and QString text();
more details ,refer Qt Assistant
Re: basic question: getting value from qwidget and use it in mainapplication
If u want to get the value of text box from a QWidget to MainWindow,
declare an instance of QWidget say MyQWidget in ur MainWindow then u can get the value by MyQWidget->MyTextBox->text();
Or if u r doing all the things in designer(i.e. u r not creating any implementation header or source file) then the place where u r actually getting the text string, store this in an extern variable and access this extern variable in ur MainWindow.
But I would not recommend this approach, its better that u should create the implementation files for both ur QWidget and MainWindow, then implement the functionality there.