i want to know how we can print any string in qt as cout and qwarning are not working.
Is there any other way for this??
please help
thanks
i want to know how we can print any string in qt as cout and qwarning are not working.
Is there any other way for this??
please help
thanks
Look for qPrintable(...) ;-)
Is QString::toLatin1() what you are looking for??
QString text="text";
int ret = QMessageBox::warning(this, tr("My Application"), text.toLatin1(), QMessageBox::Ok);
J.
The biggest difference between time and space is that you can't reuse time.
-- Merrick Furst
Hi,
If you want to use cout to print, I have attached two files to this email...qstd.cpp and qstd.h. To use the standard cout syntax include these files in your project and add the namespace using command - using namespace qstd - to any scope in which you want to use cout (and include the "qstd.h" header file of course).
I did not write these files myself, but stumbled upon them somewhere on the web while trying to solve a problem similiar to yours when I first started with Qt. I give full credit, thanks and kudo's to the unamed author....cout has worked flawlessly for me.
Hope this helps....
tim
If you just want to print one or two you can always use the toStdString() method. So:
Qt Code:
std::cout<<str.toStdString()<<std::endl;To copy to clipboard, switch view to plain text mode
would print
i still like using the good old printf:
QString str;
printf("%s\n", str.toLatin1().constData());
fflusg(stdout);
regards,
jh
i use
Qt Code:
qDebug() << "hello world";To copy to clipboard, switch view to plain text mode
Bookmarks