QString to char* conversion

前端 未结 10 2110
予麋鹿
予麋鹿 2020-11-27 02:57

I was trying to convert a QString to char* type by the following methods, but they don\'t seem to work.

//QLineEdit *line=new QLineEdit();{just to describe w         


        
10条回答
  •  我在风中等你
    2020-11-27 03:09

    It is a viable way to use std::vector as an intermediate container:

    QString dataSrc("FooBar");
    QString databa = dataSrc.toUtf8();
    std::vector data(databa.begin(), databa.end());
    char* pDataChar = data.data();
    

提交回复
热议问题