qt in argv [1] parameter passed in the garbage problem

Program parameters passed

The file path as a parameter passed to the program, if the file path contains Chinese, Chinese resolves not come out, try a variety of methods, using fromLocal8Bit method.

    char* fileDp = argv[1];
	QString filePath = QString::fromLocal8Bit(fileDp);
	QFile fileInfo(filePath);
	qDebug() << fileInfo.fileName;

QFile method QT is provided a method of direct access to the file name, filePath is the path to the current file.

He published 192 original articles · won praise 27 · Views 100,000 +

Guess you like

Origin blog.csdn.net/lovely_girl1126/article/details/103879558