Book Image

Qt5 C++ GUI Programming Cookbook

By : Lee Zhi Eng
Book Image

Qt5 C++ GUI Programming Cookbook

By: Lee Zhi Eng

Overview of this book

With the advancement of computer technology, the software market is exploding with tons of software choices for the user, making their expectations higher in terms of functionality and the look and feel of the application. Therefore, improving the visual quality of your application is vital in order to overcome the market competition and stand out from the crowd. This book will teach you how to develop functional and appealing software using Qt5 through multiple projects that are interesting and fun. This book covers a variety of topics such as look-and-feel customization, GUI animation, graphics rendering, implementing Google Maps, and more. You will learn tons of useful information, and enjoy the process of working on the creative projects provided in this book
Table of Contents (16 chapters)
Qt5 C++ GUI Programming Cookbook
About the Author
About the Reviewer

Rendering 2D shapes

Since we have already learned how to draw our first rectangle on the screen, we will further enhance it in this section. We will take the previous example and continue from there.

How to do it…

  1. First, go to the paintGL() function in mainwindow.cpp and replace the quad in the previous example with new code. This time, we draw a quad together with a triangle:

    void MainWindow::paintGL()
      // Initialize clear color (cornflower blue)
      glClearColor(0.39f, 0.58f, 0.93f, 1.f);
      // Clear color buffer
      glVertex2f(-0.5f, -0.5f);
      glVertex2f(0.5f, -0.5f);
      glVertex2f(0.5f, 0.5f);
      glVertex2f(-0.5f, 0.5f);
        glColor3f(1.f, 0.f, 0.f); glVertex2f(-0.8f, -0.8f);
        glColor3f(1.f, 1.f, 0.f); glVertex2f(0.3f, -0.8f);
        glColor3f(0.f, 1.f, 0.f); glVertex2f(0.3f, 0.3f);
        glColor3f(0.f, 0.f, 1.f); glVertex2f(-0.8f, 0.3f);
        glColor3f(1.f, 0.f, 0.f); glVertex2f...