码迷,mamicode.com
首页 > 其他好文 > 详细

Qt编译OpenGL程序遇到的问题

时间:2014-09-30 13:23:54      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:c++   qt   opengl   

软件版本:
Qt 4.8.5
按照网上的例程(http://www.qiliang.net/old/nehe_qt/lesson01.html),跑了一下基于Qt Creator的OpenGL。由于上述例程的Qt版本较老(例程是02年的,汗!),在新的Qt环境下产生诸多问题,好在一一得到了解决,现说明如下:

1、需要在工程文件.pro中添加对OpenGL的支持:
QT += opengl(记得清理项目后再编译!)
否则会出现一大堆类似error: undefined reference to `glShadeModel@4‘、error: undefined reference to `glClearColor@16‘的问题。
bubuko.com,布布扣

2、对于设置窗口Title的函数setCaption:
[error: ‘setCaption‘ was not declared in this scope]
在新版本中已经废弃,改而用setWindowTitle()函数代替:
setCaption("Qt Open-GL");——>setWindowTitle("Qt Open-GL");

3、对于glu开头的函数,如gluPerspective():
[error: ‘gluPerspective‘ was not declared in this scope]
需要包含头文件
#include <GL/glu.h> 

4、用到QKeyEvent,需要包含其头文件
[error: invalid use of incomplete type ‘struct QKeyEvent‘]
#include <QKeyEvent>

Qt编译OpenGL程序遇到的问题

标签:c++   qt   opengl   

原文地址:http://blog.csdn.net/u013686019/article/details/39692453

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!