Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Problems when running the first program in QT Creator with OpenGL
Forum Updated to NodeBB v4.3 + New Features

Problems when running the first program in QT Creator with OpenGL

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
2 Posts 2 Posters 486 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Areyeslo
    wrote on last edited by
    #1

    Hi everyone,

    Hi,
    I am trying to run basic examples of OpenGL using QT Creator to give color to a window. However, I am getting error in the compilation when calling the OpenGL instruction:
    glClearColor(1.0,1.0,0.0,1.0);

    The *.pro file is the next:
    QT += core gui opengl
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = test2
    TEMPLATE = app
    SOURCES += main.cpp
    mainwindow.cpp
    glwidget.cpp
    HEADERS += mainwindow.h
    glwidget.h
    FORMS += mainwindow.ui

    The glwidget.h is the next:
    #ifndef GLWIDGET_H
    #define GLWIDGET_H
    #include <QGLWidget>
    class GLWidget : public QGLWidget
    {
    Q_OBJECT
    public:
    explicit GLWidget(QWidget *parent = 0);
    void initializeGL();
    };
    #endif // GLWIDGET_H

    The glwidget.cpp is the next:
    #include "glwidget.h"
    GLWidget::GLWidget(QWidget *parent) :
    QGLWidget(parent)
    {
    }
    void GLWidget::initializeGL(){
    glClearColor(1.0,1.0,0.0,1.0);
    }

    The main.cpp:
    #include "mainwindow.h"
    #include <QApplication>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
    }

    I have checked that in the *.pro I have included opengl:
    QT += core gui opengl
    In addition, I have deleted the YourProjectName-build-desktop folder and build again without success.

    Which extra step I am missing?

    Thank you in advance for your help

    Cheers

    1 Reply Last reply
    0
    • ValentinMicheletV Offline
      ValentinMicheletV Offline
      ValentinMichelet
      wrote on last edited by
      #2

      Hi,

      Could you show us the error message please?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved