我对编程和使用qt创建自己的GUI非常陌生。我试图使搜索栏成为我的列表视图之一,但它一直说没有匹配函数可调用.这可能是个很愚蠢的问题。这是我的密码。
void Widget::on_SearchBar_textChanged(const QString &arg1)
{
QString Input;
ui->Online->find(Input);
}和错误
C:\Qt\Qt5.1.1\Tools\QtCreator\bin\CryptoCourier\widget.cpp:21:错误:没有调用'QListWidget::find(QString&)‘的匹配函数
ui->Online->find(Input);下面是我所要求的其余代码
好的,这是我剩下的代码。不多,但在这里。
#include "widget.h"
#include "ui_CryptoCC.h"
#include <QString>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_SearchBar_textChanged(const QString &arg1)
{
#include <string>
QString Input;
ui->Online->find(Input);
}
^发布于 2013-10-15 00:24:32
你有两个主要问题:
#include语句应该超出函数的范围,因为它们实际上包括了,这是一个完整的文件,就在您放置它们的地方。QString,您想要包含的文件可能称为"QString“。试着做这样的事情:
#include <QString>
/* the rest of your code, which you didn't include in your example */
void Widget::on_SearchBar_textChanged(const QString &arg1)
{
/* by the way, you're calling Online->find() with an empty string,
* did you mean to use `arg1` here? */
QString Input;
ui->Online->find(Input);
}除此之外,我还需要知道ui和ui->Online是什么,然后我才能给您提供关于可以调用它们的函数的建议。
https://stackoverflow.com/questions/19371142
复制相似问题