gpt4 book ai didi

c++ - 错误 : no matching function for call to 'QLabel::text(QString&)'

转载 作者:可可西里 更新时间:2023-11-01 09:58:59 25 4
gpt4 key购买 nike

我尝试制作文件浏览器,但出了什么问题

这是我的mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}

MainWindow::~MainWindow()
{
delete ui;
}

void MainWindow::on_pushButton_4_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),
"",
tr("Files (*.mp3 *.ogg)"));
ui->label->text(fileName);
}

错误:

C:\Users\account\eka\mainwindow.cpp:24: error: no matching function for call to 'QLabel::text(QString&)'
ui->label->text(fileName);
^

我刚开始使用 Qt,请帮助我。

最佳答案

使用 setText() 而不是 text()。 text() 是一个 setter/getter

ui->label->setText(fileName);

关于c++ - 错误 : no matching function for call to 'QLabel::text(QString&)' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26742357/

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