我一直在寻找有关此问题的信息..但我找到的解决方案都没有帮助我,我真的希望你能帮助我
maintabholder.h:
#ifndef MAINTABHOLDER_H #define MAINTABHOLDER_H #include <QMainWindow> namespace Ui { class MainTabHolder; } class MainTabHolder : public QMainWindow { Q_OBJECT public: explicit MainTabHolder(QWidget *parent = 0); ~MainTabHolder(); private: Ui::MainTabHolder *ui; }; #endif // MAINTABHOLDER_H
maintabholder.cpp:
#include "maintabholder.h" #include "ui_maintabholder.h" MainTabHolder::MainTabHolder(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainTabHolder) { ui->setupUi(this); } MainTabHolder::~MainTabHolder() { delete ui; }
主.cpp:
#include "maintabholder.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainTabHolder w; w.show(); return a.exec(); }
ui_maintabholder.h #ifndef UI_MAINTABHOLDER_H #define UI_MAINTABHOLDER_H
#include <QtCore/QVariant> #include <QtWebKitWidgets/QWebView> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QHBoxLayout> #include <QtWidgets/QHeaderView> #include <QtWidgets/QPushButton> #include <QtWidgets/QSpacerItem> #include <QtWidgets/QTabWidget> #include <QtWidgets/QVBoxLayout> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_Form { public: QHBoxLayout *horizontalLayout; QTabWidget *tabWidget; QWidget *comicViewer; QWidget *comicSearcher; QVBoxLayout *verticalLayout; QHBoxLayout *horizontalLayout_2; QPushButton *pushButton; QSpacerItem *horizontalSpacer; QPushButton *pushButton_2; QWebView *webView; void setupUi(QWidget *Form) { if (Form->objectName().isEmpty()) Form->setObjectName(QStringLiteral("Form")); Form->resize(531, 308); horizontalLayout = new QHBoxLayout(Form); horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); tabWidget = new QTabWidget(Form); tabWidget->setObjectName(QStringLiteral("tabWidget")); comicViewer = new QWidget(); comicViewer->setObjectName(QStringLiteral("comicViewer")); comicViewer->setCursor(QCursor(Qt::ArrowCursor)); tabWidget->addTab(comicViewer, QString()); comicSearcher = new QWidget(); comicSearcher->setObjectName(QStringLiteral("comicSearcher")); verticalLayout = new QVBoxLayout(comicSearcher); verticalLayout->setObjectName(QStringLiteral("verticalLayout")); horizontalLayout_2 = new QHBoxLayout(); horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2")); pushButton = new QPushButton(comicSearcher); pushButton->setObjectName(QStringLiteral("pushButton")); horizontalLayout_2->addWidget(pushButton); horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); horizontalLayout_2->addItem(horizontalSpacer); pushButton_2 = new QPushButton(comicSearcher); pushButton_2->setObjectName(QStringLiteral("pushButton_2")); pushButton_2->setEnabled(false); horizontalLayout_2->addWidget(pushButton_2); verticalLayout->addLayout(horizontalLayout_2); webView = new QWebView(comicSearcher); webView->setObjectName(QStringLiteral("webView")); webView->setUrl(QUrl(QStringLiteral("about:blank"))); verticalLayout->addWidget(webView); tabWidget->addTab(comicSearcher, QString()); horizontalLayout->addWidget(tabWidget); retranslateUi(Form); tabWidget->setCurrentIndex(1); QMetaObject::connectSlotsByName(Form); } // setupUi void retranslateUi(QWidget *Form) { Form->setWindowTitle(QApplication::translate("Form", "Form", 0)); tabWidget->setTabText(tabWidget->indexOf(comicViewer), QApplication::translate("Form", "Comic Viewer", 0)); pushButton->setText(QApplication::translate("Form", "Go to SubManga", 0)); pushButton_2->setText(QApplication::translate("Form", "Download Comic", 0)); tabWidget->setTabText(tabWidget->indexOf(comicSearcher), QApplication::translate("Form", "Search For Comics", 0)); } // retranslateUi }; namespace Ui { class Form: public Ui_Form {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_MAINTABHOLDER_H
编译器错误是:
[...]\maintabholder.cpp: In constructor 'MainTabHolder::MainTabHolder(QWidget*)':
[...]\maintabholder.cpp:6:16: error: invalid use of incomplete type 'class Ui::MainTabHolder'
In file included from [...]\maintabholder.cpp:1:0:
[...]\maintabholder.h:7:7: error: forward declaration of 'class Ui::MainTabHolder'
[...]\maintabholder.cpp:8:7: error: invalid use of incomplete type 'class Ui::MainTabHolder'
In file included from [...]\maintabholder.cpp:1:0:
[...]\maintabholder.h:7:7: error: forward declaration of 'class Ui::MainTabHolder'
[...]\maintabholder.cpp: In destructor 'virtual MainTabHolder::~MainTabHolder()':
[...]\maintabholder.cpp:13:12: warning: possible problem detected in invocation of delete operator: [enabled by default]
[...]\maintabholder.cpp:13:12: warning: invalid use of incomplete type 'class Ui::MainTabHolder' [enabled by default]
In file included from [...]\maintabholder.cpp:1:0:
[...]\maintabholder.h:7:7: warning: forward declaration of 'class Ui::MainTabHolder' [enabled by default]
[...]\maintabholder.cpp:13:12: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
你能帮忙吗?我会很感激...