-2
参数我有一个Qt工程的Windows用户界面,我想这个UI的参数传递到另一个函数,这样的:通UI在Qt的
ConfWindows::ConfWindows(QWidget *parent) :
QDialog(parent),
ui(new Ui::ConfWindows)
{
ui->setupUi(this);
connect(ui->add_button, SIGNAL(clicked()), this, SLOT(add_elem(ui->name_edit)));
}
void add_elem(QLabel test)
{
qDebug() << test.text();
}
,但我得到一个错误,当我尝试做即:
'QLabel::QLabel(const QLabel&)' is private
Q_DISABLE_COPY(QLabel)
在参数中传递UI元素是不可能的?
感谢您的帮助。
传递'const&'? – LogicStuff
是这样的? (void)add_elem(QLabel const&test) { qDebug()<< test.text(); }' 我得到这个错误: '未定义参考ConfWindows :: add_elem(QLabel常量&)' 但是,add_elem是一个插槽,所以他不需要 “ConfWindows ::” 以前吧? – R3J3CT
不应该是'SLOT(add_elem(QLabel)));'首先呢?另外,复制被禁用,通过const引用传递。 – xinaiz