1.创建一个Qt gui application工程,使用设计器调出一个tabwidget控件,如下图
2.pro文件如下
QT += opengl
# LIBS+=-IGLU
LIBS += -lglut \
-lGLU
TARGET = .
TEMPLATE = app
SOURCES += main.cpp \
mainwindow.cpp \
nehewidget.cpp
HEADERS += mainwindow.h \
nehewidget.h
FORMS += mainwindow.ui
3.输入命令产生makefile文件,记得一定先查看qmake版本是否正确
4.输入$make ,产生ui_ mainwindow.h文件,然后修改ui_ mainwindow.h文件如下(红色为修改的地方)
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created by: Qt User Interface Compiler version 4.8.6
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_MAINWINDOW_H
#define UI_MAINWINDOW_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QHeaderView>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include <QtGui/QPushButton>
#include <QtGui/QStatusBar>
#include <QtGui/QTabWidget>
#include <QtGui/QToolBar>
#include <QtGui/QWidget>
<span style="color:#CC0000;">include "nehewidget.h"</span>
QT_BEGIN_NAMESPACE
class Ui_MainWindow
{
public:
QWidget *centralWidget;
QTabWidget *tabWidget;
QWidget *tab;
QPushButton *pushButton;
<span style="color:#FF0000;">NeHeWidget </span>tab_2;
QPushButton *pushButton_2;
QMenuBar *menuBar;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *MainWindow)
{
if (MainWindow->objectName().isEmpty())