槽函数连接不上的问题~~
哪位大神能帮我看看这段代码呢,我的槽函数连接不上,提示invalid ues of 'this' in non-member function
ps:谢谢下午storylsl大神的解答,可是问题还是木有解决,我想重新定义头文件和实现文件,但不知道该怎么写了。。。
#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();}
谁能先帮我改了这个错误呢,或者谁能帮我分开写一下么,我实在不知道该如何分别实现QWizardPage 类了~~
[解决办法]
还是画界面吧,快着呢。你不用QtCreator?
手写需要每个页面继承一次,写一个类。
画界面,点QtCreator菜单,文件->新建->对话框坐下点Qt->右上点设计师界面类->点按钮“选择”->在新页面里左边点“窗口部件”->QWidget就在倒数第二个,继续就可以了。