0
点赞
收藏
分享

微信扫一扫

Qt报错:reference to non-static member function must be called; did you mean to call it with no argumen


Qt开发,一行代码报错:

reference to non-static member function must be called; did you mean to call it with no arguments?

代码:

if (tbxD.toPlainText().trimmed().length == 0) { ... }
if (tbxM.toPlainText().trimmed().length == 0) { ... }
if (tbxS.toPlainText().trimmed().length == 0) { ... }

这几行代码看上去没什么特别的,就是取了EditText输入框控件的文字而已,为什么会提示什么 non-static呢?

研究了一会儿,发现了问题,代码中要取字符串的长度,不能用length属性,而应该用length()方法:

if (tbxD.toPlainText().trimmed().length() == 0) { ... }
if (tbxM.toPlainText().trimmed().length() == 0) { ... }
if (tbxS.toPlainText().trimmed().length() == 0) { ... }

问题解决。


举报

相关推荐

0 条评论