gpt4 book ai didi

c++ - Qt Creator 和 Qstring

转载 作者:行者123 更新时间:2023-11-30 02:51:54 25 4
gpt4 key购买 nike

我不熟悉编程和使用 qt 创建我自己的 GUI。我正在尝试使搜索栏成为我的 ListView 之一,但它一直说没有匹配的函数可以调用...这可能是一个非常愚蠢的问题。这是我的代码。

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: error: no matching function for call to '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);
}

除此之外,我还需要知道什么是 uiui->Online,然后才能就可以调用它们的函数向您提供建议。

关于c++ - Qt Creator 和 Qstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19371142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com