Have you looked at the QMessageBox class? Maybe even one of the static functions (like QMessageBox::information()) is enough.
Have you looked at the QMessageBox class? Maybe even one of the static functions (like QMessageBox::information()) is enough.
"The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry
@untamed:
you should know that these kind of requests are not seen favorably on forums such as this one.
We gladly help, but you should show that you are trying to solve your problem your self.
So, show us what it is you have tried, and where exaclty your problem leis.
We will help you then to solve your specific problem.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
In general, you are right. You don't ask someone else to write code for you.
But I can understand that if you're in a real hurry, you don't have time to do much research yourself. (Though you shouldn't disguise every question as such.)
This forum is not here for nothing. And he did post in the newbie section. You should just point him in the right direction (as I did). The Qt library is quite big. I've been known to ask for directions myself.
"The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry
but what exactly did you answer to in my post?
Yes, this forum is not here for nothing, but also not for people to get thier "home work" done for them.
Even if someone is in a hurry, he/she should at least TRY SOMETHING.
Being in a hurry is no reason not to do ANYTHING.
Since the question is SO general, I could not see where to forward him to.
You suggested QMessageBox.
That is a valid oppinion, but I see no reason to bring QMessageBox up at all.
If anything then:
QDialog,QPushBUtton,QTextEdit and general reading about signals/slots.
There - is that better?![]()
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Sure. You should know how these things work. But if you quickly want to display a message in a popup window, that's what QMessageBox is for. Why reinvent the wheel?
"The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry
because he wanted something which you can't do with a QMessageBox (unless you subclass it) - QMessageBox has no input fields.Why reinvent the wheel?
Could anybody please give me a code snippet which has a text input field and a button. If we enter some text into the text field and press the button, it should pop a new window with the same text inside.
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Yes, of course. I was just assuming (for some reason) that the popup-window was the thing he had trouble with. Not the textfield and the button.Mea culpa.
"The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry
I am really sorry to have asked such a question.
I was in a hurry then, and i was thinking like if I happen to get some code, I can read and understand from that. I dint mean anybody to do my homework.
hmm, I am quite new into this thing and even C++ too.
So, I have created the first dialog with a text input filed and two buttons, ok and cancel. I havent used designer. I want to pop another dialog[or an alert] with the text copied from the first dialog's text input field when OK button is pressed. I know that i can pass the text through a string literal. How do i create that second dialog, thats my issue now. Will QMessageBox do?
QMessageBox doesnt take inputs?
I got this info from the documentation:
QMessageBox::information ( QWidget * parent, const QString & title, const QString & text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton )
so, I think the third field, const QString & text can be used to pass the text. Am I correct?
so I can avoid creating a second dialog. My application[the actual assignment given] requires the use of alertboxes more, and if QMessageBox can take variables[strings] as inputs, it will be easy. Could anybody please clarify on this?
Thank you.![]()
I think this chunk of code is the core:
void textdialog:op()
{
QString text = textedit->toHtml();
QMessageBox::StandardButton ok;
ok = QMessageBox::information(this, tr("Popped!"), tr("<p>You had entered:</p>""<p>%1</p>") .arg(text));
}
QMessageBox can take inputs.
when the OK button is pressed, it calls the pop() function.
Thanks everyone, I did it. Thanx Michiel for the understanding you showed. Thanks a lot to Sunil.Thaha for his patience when i disturbed him with silly doubts and for guiding me through each n every step.![]()
I think this chunk of code is the core:
Qt Code:
void textdialog::pop() { ok = QMessageBox::information(this, tr("Popped!"), tr("<p>You had entered:</p>""<p>%1</p>") .arg(text)); }To copy to clipboard, switch view to plain text mode
QMessageBox can take inputs.
when the OK button is pressed, it calls the pop() function.
Thanks everyone, I did it. Thanx Michiel for the understanding you showed. Thanks to high_flyer for challenging me.
Thanks a lot to Sunil.Thaha for his patience when i disturbed him with silly doubts and for guiding me through each n every step.![]()
Last edited by untamed; 5th June 2007 at 08:57. Reason: missing [code] tags
No it can't.QMessageBox can take inputs.
The FUNCTION (in this case a static function) takes "input" parameters.
But not the DIALOG.
Its not the same.
The input came from the QTextEdit widget, which you passed to the message box as a parameter.
Looks like end titels of a movie... or an oscar winner speachThanks everyone, I did it. Thanx Michiel for the understanding you showed. Thanks to high_flyer for challenging me .
Thanks a lot to Sunil.Thaha for his patience when i disturbed him with silly doubts and for guiding me through each n every step.![]()
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Bookmarks