#include "mainwindow.h"

#include "ui_mainwindow.h"
#include<QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    //测试文件
    QString cr2FilePath="abc";
    char *fn = cr2FilePath.toLocal8Bit().data();
    qDebug()<<fn;  //<=========================================这里有时候输出 abc ,有时候输出a
    qDebug()<<endl;

    QByteArray text = cr2FilePath.toLocal8Bit();
    char * fn2 =   new char[text.size() + 1];
    strcpy(fn2, text.data());  //<=====================这里又是正确的
        qDebug()<<fn2<<endl;
}

测试环境:Qt5.2.1 mingw
win8.1 中文 64bit

相关文章:

  • 2021-10-06
  • 2021-11-15
  • 2021-12-18
  • 2022-01-20
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-14
  • 2021-09-07
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案