Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 5.1.1 Android: How to initialize and show OpenGL window on GUI event?
Forum Updated to NodeBB v4.3 + New Features

Qt 5.1.1 Android: How to initialize and show OpenGL window on GUI event?

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 1.3k 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.
  • T Offline
    T Offline
    Thomas13
    wrote on 3 Oct 2013, 11:06 last edited by
    #1

    Hello everybody,

    I need to initialize and show OpenGL window not while application starts but by GUI event like QPushButton::clicked().

    I am trying to run the 'openglwindow' Qt 5.1.1 example on Android 4.0.4 Samsung Galaxy Tab 2. The original project builds and runs correctly. I can see a rotating triangle.

    Then I try to do TriangleWindow.show() by event not in main() function. Expose event passes successfully but the application crashes in OpenGLWindow::renderNow() function on initializeOpenGLFunctions().

    How can I initialize and show OpenGLWindow on event correctly?

    @
    #include "MainWindow.h"
    #include "TriangleWindow.h"

    #include <QVBoxLayout>
    #include <QPushButton>
    #include <QSurfaceFormat>

    CMainWindow::CMainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    QSurfaceFormat format;
    format.setSamples(16);

    m_pTriangleWindow = new TriangleWindow;
    m_pTriangleWindow->setFormat(format);
    
    m_pTriangleWindow->resize(640, 480);
    m_pTriangleWindow->setPosition(5000, 5000);
    
    m_pWidgetStack = new QStackedWidget(this);
    
    QWidget*        pFirstPage  = new QWidget(m_pWidgetStack);
    QPushButton*    pPushButton = new QPushButton("Start Triangle window", m_pWidgetStack);
    QVBoxLayout*    pLayout     = new QVBoxLayout;
    
    connect(pPushButton, SIGNAL(clicked()), this, SLOT(SelectSecondPage()));
    
    pLayout->addStretch();
    pLayout->addWidget(pPushButton);
    pLayout->addStretch();
    
    pFirstPage->setLayout(pLayout);
    m_pWidgetStack->addWidget(pFirstPage);
    
    m_pSecondPage = new QWidget(m_pWidgetStack);
    m_pWidgetStack->addWidget(m_pSecondPage);
    
    setCentralWidget(m_pWidgetStack);
    m_pWidgetStack->setCurrentIndex(0);
    

    }

    CMainWindow::~CMainWindow()
    {
    m_pTriangleWindow->deleteLater();
    }

    void CMainWindow::SelectSecondPage()
    {
    m_pWidgetStack->setCurrentIndex(1);

    m_pTriangleWindow->show();
    m_pTriangleWindow->setAnimating(true);
    

    }

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    CMainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }
    @

    Application output:
    @
    Debugging starts
    Could not load shared library symbols for 71 libraries, e.g. /system/bin/linker.
    Use the "info sharedlibrary" command to see the complete listing.
    Do you need "set solib-search-path" or "set sysroot"?Unable to find dynamic linker breakpoint function.
    GDB will retry eventurally. Meanwhile, it is likely
    that GDB is unable to debug shared library initializers
    or resolve pending breakpoints after dlopen().I/Qt JAVA (27127): DEBUGGER: waiting for pong at /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow, attempt 3
    I/Qt JAVA (27127): DEBUGGER: got pong /data/local/tmp/qt/debug-pong-org.qtproject.example.OpenGLWindow
    W/Qt (27127): ../src/androidjnimain.cpp:449 (jboolean startQtApplication(JNIEnv*, jobject, jstring, jstring)): Can't set environment ""
    W/Qt (27127): kernel/qcoreapplication.cpp:412 (QCoreApplicationPrivate::QCoreApplicationPrivate(int&, char**, uint)): WARNING: QApplication was not created in the main() thread.
    D/libEGL (27127): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
    D/libEGL (27127): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
    D/libEGL (27127): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
    W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtNativeInputConnection'
    W/dalvikvm(27127): dvmFindClassByName rejecting 'org/qtproject/qt5/android/QtExtractedText'
    D/Qt (27127): ../OpenGLWindow/openglwindow.cpp:118 (virtual void OpenGLWindow::exposeEvent(QExposeEvent*)): exposeEvent passed
    E/libEGL (27127): eglMakeCurrent:674 error 3009 (EGL_BAD_MATCH)
    W/Qt (27127): eglconvenience/qeglplatformcontext.cpp:111 (virtual bool QEGLPlatformContext::makeCurrent(QPlatformSurface*)): QEGLPlatformContext::makeCurrent: eglError: 3009, this: 0x2098190
    W/Qt (27127):
    Debugging has finished
    @

    1 Reply Last reply
    0

    1/1

    3 Oct 2013, 11:06

    • 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