首页 > 其他 > 详细

Qt编译OpenGL程序遇到的问题

时间:2014-09-30 11:31:24      阅读:363      评论:0      收藏:0      [点我收藏+]
软件版本:
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程序遇到的问题

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!