Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Qt5 C++ GUI Programming Cookbook

You're reading from   Qt5 C++ GUI Programming Cookbook Design and build a functional, appealing, and user-friendly graphical user interface

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781783280278
Length 300 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Lee Zhi Eng Lee Zhi Eng
Author Profile Icon Lee Zhi Eng
Lee Zhi Eng
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Look and Feel Customization FREE CHAPTER 2. States and Animations 3. QPainter and 2D Graphics 4. OpenGL Implementation 5. Building a Touch Screen Application with Qt5 6. XML Parsing Made Easy 7. Conversion Library 8. Accessing Databases 9. Developing a Web Application Using Qt Web Engine Index

Setting up OpenGL in Qt

In this recipe, we will learn how to set up OpenGL in Qt.

How to do it…

  1. First, let's create a new Qt widgets application by going to File | New File or Project.
  2. Next, we will remove the mainwindow.ui file because we are not going to use it in this example. Right-click on the mainwindow.ui file and select Remove File from the drop-down menu. Then, a message box will appear and ask for your confirmation. Tick Delete file permanently and press the OK button.
  3. After that, open up your project file (.pro) and add the OpenGL module to your project by adding an opengl keyword behind QT +=, like so:
    QT += core gui opengl
  4. You also need to add another line in your project file so that it will load both the OpenGL and GLu (OpenGL Utilities) libraries during startup. Without these two libraries, you program will not be able to run:
    LIBS += -lopengl32 -lglu32
  5. Then, open up mainwindow.h and remove several things from it:
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include &lt...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime