我是編程和使用qt創建自己的GUI的新手。我試圖讓我的列表視圖的搜索欄之一,但它一直說沒有匹配的函數來調用......這可能是一個非常愚蠢的問題。這是我的代碼。Qt Creator和Qstring
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);
}
^
您正在調用QListWidget實例'Online'的'find'方法。這個方法在這裏描述:http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#find。它與搜索沒有任何關係,而是將本機窗口小部件句柄映射回QWidgets(並且不需要QString參數)。也許包括一個你想要完成的小UI模型,然後人們將能夠得到更多的幫助。 – ksimons
提示:你不能通過拼湊隨機的東西來編寫程序;首先學習語言,然後學習Qt框架的一些基礎知識,並且總是閱讀你不知道的方法的文檔。 –
噢。我忘了拿出來。我修好了。 – noahdotgansallo