Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [QOpenGLWidget] image overshadows main windows
Forum Update on Monday, May 27th 2025

[QOpenGLWidget] image overshadows main windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 366 Views
  • 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.
  • D Offline
    D Offline
    debian
    wrote on 6 Nov 2015, 08:56 last edited by
    #1

    Hello!
    I use qt-5.5.1 on Linux x64.
    In application main window I add QOpenGLWidget and inherit from it to subclass.
    Follow subclass code:
    GLWidget::GLWidget(QWidget *parent) :
    QOpenGLWidget(parent)
    {}
    GLWidget::~GLWidget()
    {
    glDeleteTextures(CHANNEL_MAX, _texture);
    }
    void GLWidget::add(QImage image, quint8 pos)
    {
    if (pos < CHANNEL_MAX) {
    qDebug() << func << "add position" << pos;
    glActiveTexture(GL_TEXTURE0 + pos);
    glBindTexture(GL_TEXTURE_2D, _texture[pos]);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(),
    0, GL_RGB, GL_UNSIGNED_BYTE, image.constBits());
    update();
    }
    }
    void GLWidget::initializeGL()
    {
    initializeOpenGLFunctions();
    glClearColor(0, 0, 0, 1);
    glEnable(GL_TEXTURE_2D);
    glGenTextures(CHANNEL_MAX, _texture);
    }
    void GLWidget::paintGL()
    {
    qDebug() << func;
    glDrawArrays(GL_TEXTURE_2D_ARRAY, _texture[0], CHANNEL_MAX);
    }
    void GLWidget::resizeGL(int w, int h)
    {}

    All work, but I have several problems:

    • image overshadows mainwindows
    • I always see only one image, but I wait several images to one line

    How can I solve this problem?
    Thank you and excuse my bad english.

    1 Reply Last reply
    0

    1/1

    6 Nov 2015, 08:56

    • Login

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