二进制ASCII到QString并将所述QString写入PlainTextEdit小部件

时间:2017-08-04 02:21:38

标签: c++ qt

我正在阅读的文件的每个字节对应一个ascii或ebcdic字符。程序中的所有内容都可以正常工作,在Visual Studio中使用和不使用bugger进行测试,但是行textualFileCharacterString = QString::fromAscii(currentCharacterPointer, -1);向我发出fromAscii()不存在的警告,奇怪的是fromUni8()确实存在并且fromLatin1()也是如此。如果您查看下面链接的Qt文档,您可以看到fromAscii()应该仍然存在。是否有一个我缺少的包含文件/有不同的方式我可以将二进制Ascii转换为QString。以下是我的代码部分,其中包含问题和包含。 http://doc.qt.io/qt-4.8/qstring.html#fromAscii

#include <istream>
#include <fstream>
#include <iostream>
#include <QString>

#define BUF_LEN_1 1
#define FALSE 0
#define TRUE 1

//跳转代码

   QString textualFileCharacterString;
    char currentCharacter;
    const char* currentCharacterPointer = &currentCharacter;
    while (bytePosition < 3200)
    {
        for(count = 0; count < 80; count ++)
        {
            file.seekg(bytePosition);
            file.read((char*)(&ASCIIorEBCDICchar[0]), BUF_LEN_1);
            if (EBCDICtoASCIIConvNeeded == TRUE)
                currentCharacter = ebc_to_ascii_table(ASCIIorEBCDICchar[0]); // file is encoded in ASCII
            else
                currentCharacter = ASCIIorEBCDICchar[0]; // file is encoded in EBCDIC
            textualFileCharacterString = QString::fromAscii(currentCharacterPointer, -1);
            ui->TextualFileHeaderPlainTextEdit->insertPlainText(textualFileCharacterString);
            count++;
            bytePosition++;
        }
        ui->TextualFileHeaderPlainTextEdit->insertPlainText("\n");
    }
    ui->TextualFileHeaderPlainTextEdit->insertPlainText("done");
    ui->TextualFileHeaderPlainTextEdit->setReadOnly(true);
}

0 个答案:

没有答案