Qt Creator and Qstring
Qt Creator and Qstring
我是编程新手,使用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);
}
^
您有两个主要问题:
-
#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
是什么,然后才能给你建议,你可以调用它们什么功能。
相关文章:
- 将 Qvector<uint8_t> 转换为 QString
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- 为什么 Clang 不允许"and"作为函数名称?
- 位阵列上的快速AND运算
- 如何通过按下第三个窗口中的按钮,将QString从一个窗口获取到另一个窗口
- 是否可以在 C++03 中定义'move-and-swap idiom'等效项
- BoostPython and CMake
- OpenSSL BIO and SSL_read
- Gurobi GRBModel and GRBmodel in C++
- QStringList vs list<shared_ptr<QString>> 性能比较C++
- 将 hh:mm:ss.zzz 时间 QString 转换为毫秒的单行函数?
- std::visit and std::variant usage
- SHBrowseForFolder with BIF_BROWSEFORCOMPUTER and SHGetPathFr
- Directx12 and keystrokes
- different between int **arr =new int [ n]; and int a[i][j]?
- C++ getenv and setenv
- Inference pytorch C++ with alexnet and cv::imread image
- Qt Creator and Qstring
- GoogleMock and QString argument