0

A Qt 4.8.1 C++ console application using OpenCV 2.4.2 is reading and displaying USB webcam images via the highgui module. It creates a window for displaying an image (using Qt internally itself I think) using the function

void namedWindow(const string& winname, int flags=WINDOW_AUTOSIZE )

However, I am missing how to convert the string to a format that does not end up as unreadable / scrambled / garbage characters. This is what I have tried:

QString windowname = "My View";
namedWindow( windowname.toStdString() );

How can the QString be converted to something the function displays correctly?

László Papp
  • 51,870
  • 39
  • 111
  • 135
handle
  • 5,859
  • 3
  • 54
  • 82

1 Answers1

0

Try following

QString windowname = "My View";
namedWindow( windowname.toStdString().c_str(), CV_WINDOW_AUTOSIZE );
guneykayim
  • 5,210
  • 2
  • 29
  • 61
  • namedWindow declared as: namedWindow(const string& winname, int flags=WINDOW_AUTOSIZE ); you trying to put char* instead string, it shouldn't work. But I'm not downvote you for this :) . – Andrey Smorodov Oct 21 '13 at 17:04
  • It has another overload, and it does work, I use it all the time, so you shouldn't be downvoting anyway :) – guneykayim Oct 21 '13 at 17:31