PDA

View Full Version : How to display result



sksingh73
7th June 2010, 07:35
i have just started learning qt4 to make gui for my c++ program. I have made a dialog window in which i am taking a string input from user in lineedit box. i have made a pushbutton called "generate" which when clicked by a user calls a function called hash. Actually my problem is that i want to display hash value of the string in a textedit box, but i am unable to do so. i dont how to display the result in QT. the code which i am using is
c = hash(phrase, strlen(phrase), 0);
sprintf(str, "%u", c);
textEdit->append( "hash: " + str );
please help me. i am not sure whether textedit box is correct way to display output or i can use something else also.

tbscope
7th June 2010, 08:39
If you use QCryptographicHash:

QByteArray plainText("Hello");
QByteArray hashText = hash(plainText, QCryptographicHash::Md5);
textEdit->setText(QString(hashText));

Not tested though