当前位置: 代码迷 >> QT开发 >> 槽函数连接不下的有关问题~
  详细解决方案

槽函数连接不下的有关问题~

热度:49   发布时间:2016-04-25 04:38:06.0
槽函数连接不上的问题~~
哪位大神能帮我看看这段代码呢,我的槽函数连接不上,提示invalid ues of 'this' in non-member function

ps:谢谢下午storylsl大神的解答,可是问题还是木有解决,我想重新定义头文件和实现文件,但不知道该怎么写了。。。

C/C++ code
#include <QtGui/QApplication>#include "dialog.h"#include <qwizard.h>#include <QLabel>#include <QtGui>#include <QPainter>QWizardPage *createPage2(){    QWizardPage *page2 = new QWizardPage;    page2->setTitle("page2");    QLabel *label2 = new QLabel("page2"                           ".");    label2->setWordWrap(true);///////////////////////////////////////////////////////////////    QLabel *label21;    label21 = new QLabel("UE Style(central;middle;edge):");    lineEdit21 = new QLineEdit;    label21->setBuddy(lineEdit21);    QHBoxLayout *layout21 = new QHBoxLayout;    layout21->addWidget(label21);    layout21->addWidget(lineEdit21);    QLabel *label22;    label22 = new QLabel("Number of BS:");    lineEdit22 = new QLineEdit;    label22->setBuddy(lineEdit22);    QHBoxLayout *layout22 = new QHBoxLayout;    layout22->addWidget(label22);    layout22->addWidget(lineEdit22);    QLabel *label23;    label23 = new QLabel("Number of UE:");    lineEdit23 = new QLineEdit;    label23->setBuddy(lineEdit23);    QHBoxLayout *layout23 = new QHBoxLayout;    layout23->addWidget(label23);    layout23->addWidget(lineEdit23);    QLabel *label24;    label24 = new QLabel("...:");    lineEdit24 = new QLineEdit;    label24->setBuddy(lineEdit24);    QHBoxLayout *layout24 = new QHBoxLayout;    layout24->addWidget(label24);    layout24->addWidget(lineEdit24);    QLabel *label25;    label25 = new QLabel("...:");    lineEdit25 = new QLineEdit;    label25->setBuddy(lineEdit25);    QHBoxLayout *layout25 = new QHBoxLayout;    layout25->addWidget(label25);    layout25->addWidget(lineEdit25);/////////////////////////////////////////////////////////////////    QPushButton *OKButton = new QPushButton("OK");    QVBoxLayout *leftlayout = new QVBoxLayout;    leftlayout->addLayout(layout21);    leftlayout->addLayout(layout22);    leftlayout->addLayout(layout23);    leftlayout->addLayout(layout24);    leftlayout->addLayout(layout25);    QHBoxLayout *downlayout = new QHBoxLayout;    downlayout->addLayout(leftlayout);    downlayout->addWidget(OKButton);    QVBoxLayout *layout2 = new QVBoxLayout;    layout2->addWidget(label2);    layout2->addLayout(downlayout);    page2->setLayout(layout2);    QObject::connect(OKButton, SIGNAL(clicked()), this , SLOT(save()));          ///////错误在这~~    return page2;}void Dialog::save(){    QFile file("F:/QtWorkshop/test_next/1234.txt");    file.open(QIODevice::ReadWrite|QIODevice::Text);    QTextStream in1(&file);    in1 << lineEdit21->text() << endl;    QTextStream in2(&file);    in2 << lineEdit22->text() << endl;    QTextStream in3(&file);    in3 << lineEdit23->text() << endl;    QTextStream in4(&file);    in4 << lineEdit24->text() << endl;    QTextStream in5(&file);    in5 << lineEdit25->text() << endl;}int main(int argc, char *argv[]){    QApplication app(argc, argv);    QString translatorFileName = QLatin1String("qt_");    translatorFileName += QLocale::system().name();    QTranslator *translator = new QTranslator(&app);    if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))        app.installTranslator(translator);    QWizard *wizard = new QWizard;    wizard->addPage(createPage2());    wizard->setWindowTitle("Trivial Wizard");    wizard->show();    return app.exec();}



注:代码都写在main.cpp里了,下午storylsl大神说最好分开头文件和实现文件来写,但我还是不太知道怎么写~~~新手见谅哦~~O(∩_∩)0~~
  相关解决方案