chenliang1066 发表于 2015-3-19 13:01:28

提示 error: 'class QString' has no member named 'toAscii'

我是新手,根据大神yafeilinux写的 Qt编写串口通信程序全程图文讲解的帖子尝试自己写个串口通信的软件。在最后编译的时候显示
error: 'class QString' has no member named 'toAscii'
mycom->write(ui->sendMsgLinEdit->text().toAscii());

下面是一部分代码

void MainWindow::on_sendMsgBtn_clicked(){    mycom->write(ui->sendMsgLinEdit->text().toAscii());    //以ASCII码形式将发送数据框中的数据写入串口}

另一个问题:如何以十六进制形式将数据框中的数据写入串口

谢谢!                                       

Joey_Chan 发表于 2015-3-19 13:01:29

chenliang1066 发表于 2015-3-19 16:28 static/image/common/back.gif
已经改过了还是不行,报其他的错误

那你换qt4吧。。。一个个改挺麻烦的

chenliang1066 发表于 2015-3-19 13:07:32

我的Qt版本是

sywh 发表于 2015-3-19 13:40:58

原来是基于Qt4的,你现在用的是qt5函数换掉了,。

chenliang1066 发表于 2015-3-19 13:42:57

sywh 发表于 2015-3-19 13:40 static/image/common/back.gif
原来是基于Qt4的,你现在用的是qt5函数换掉了,。

这个问题该如何解决呢,我是新手不是很熟悉

sywh 发表于 2015-3-19 13:46:35

chenliang1066 发表于 2015-3-19 13:42 static/image/common/back.gif
这个问题该如何解决呢,我是新手不是很熟悉

这个你要查下文档看qt5的函数了,我一直用Qt4,没文档。

Joey_Chan 发表于 2015-3-19 15:26:52

toLatin1()    或      toLocal8Bit()

chenliang1066 发表于 2015-3-19 16:28:06

Joey_Chan 发表于 2015-3-19 15:26 static/image/common/back.gif
toLatin1()    或      toLocal8Bit()

已经改过了还是不行,报其他的错误

yisenbaichuan 发表于 2019-2-18 19:48:08

楼主这个问题是怎么解决的,我也是和你一模一样的问题
页: [1]
查看完整版本: 提示 error: 'class QString' has no member named 'toAscii'