(Qt C ++)ui在新函数中的未声明标识符 [英] (Qt C++) ui Undeclared Identifier When in New Function
本文介绍了(Qt C ++)ui在新函数中的未声明标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
:)
我正在处理一个项目,我需要一个值(ui-> SpawnX-> value()),变量。
I am working on a project and I need to take a value (ui->SpawnX->value()) and put it into an int variable.
当我输入:
temp_int = ui->SpawnX->value();
in
void MainWindow::on_actionSave_savegame_dat_triggered()
{
int temp_int;
}
它运行良好,但是,我会有很多这些我想把它放在一个简单的函数。所以,上面我做了:
it runs flawlessly, however, I am going to have a lot of these so I want to put it in a simple function. So, above this I made:
void LevelWrite()
{
int temp_int;
temp_int = ui->SpawnX->value();
}
但是每当我运行它时,我得到一个错误,说ui:undeclared
But whenever I run it, I get an error saying "ui" : undeclared identifier
任何帮助都很棒:D
感谢
推荐答案
您需要 LevelWrite
类成员 MainWindow
ui
不是全局变量,而是 MainWindow
的类成员。
You need to make LevelWrite
class member of MainWindow
because ui
is not a global variable but a class member of MainWindow
.
这篇关于(Qt C ++)ui在新函数中的未声明标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文