<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Failure Creating QOpenGLContext in Console Based Application]]></title><description><![CDATA[<p dir="auto">Hello,<br />
My team in currently working on an application which renders an OpenGL geometry off-screen to create a bitmap. When executing this code when our application is running with a QML gui everything works as expected.</p>
<p dir="auto">However, we are currently developing Google Test, and need to unit test this functionality. Obviously with Google Test there is no GUI, and instead we are just exercising this code through a console -- this is where the issues occurring. When running the following code through google test we get an exception.</p>
<pre><code>QSurfaceFormat format;
            format.setDepthBufferSize(MinDepthBufferSize);
            format.setStencilBufferSize(StencilBufferSize);

            context = make_unique&lt;QOpenGLContext&gt;();
            context-&gt;setFormat(format);
            context-&gt;create();
</code></pre>
<p dir="auto">The read access exception occurs on 'context-&gt;create();'. Documentation on the topic of running a headless OpenGL Qt application is scarce, but everything I found suggests this isn't an issue. I've seen several postings stating that settings in the .pro to run in terminal (i.e. QT -= gui) may be causing  OPENGL to not be loaded; but with or without that line I still see the same issue.</p>
<p dir="auto">Any help would be appreciated. Thanks!</p>
]]></description><link>https://forum.qt.io/topic/109604/failure-creating-qopenglcontext-in-console-based-application</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 13:30:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/109604.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 09 Dec 2019 16:13:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Failure Creating QOpenGLContext in Console Based Application on Mon, 09 Dec 2019 20:32:15 GMT]]></title><description><![CDATA[<p dir="auto">Ah ha! Simple creating an instance of QGuiApplication at the beginning of my test has appeared to resolve this problem, at least. Thank you for the help!</p>
]]></description><link>https://forum.qt.io/post/566569</link><guid isPermaLink="true">https://forum.qt.io/post/566569</guid><dc:creator><![CDATA[Burkules]]></dc:creator><pubDate>Mon, 09 Dec 2019 20:32:15 GMT</pubDate></item><item><title><![CDATA[Reply to Failure Creating QOpenGLContext in Console Based Application on Mon, 09 Dec 2019 20:20:57 GMT]]></title><description><![CDATA[<p dir="auto">No, I am not creating a QGuiApplication , which sounds like that might be the issue...</p>
<p dir="auto">My team already had gtest framework in place, so I was hoping to piggy back off of that.</p>
<p dir="auto">Simply I've just been running:</p>
<pre><code>int main(int argc, char *argv[])
{
    ::testing::InitGoogleTest(&amp;argc, argv);
    return RUN_ALL_TESTS();
}

TEST(PEGTestCase, PEGTestSet)
{
    QObjectToTest object = new QObjectToTest();
    int qty = object-&gt;GetZero();
    EXPECT_EQ(qty, 0);
    ASSERT_THAT(0, Eq(0));
}
</code></pre>
<p dir="auto">The objects I've been initializing have been QObjects, and things have been working well thus far. Of course they have not had any GUI components, which would explain my need for not needing a QGuiApplication.</p>
<p dir="auto">Is it possible to integrate a QGuiApplication into this setup you could point me towards, or am I looking at using QTest to solve this issue? Thank you!</p>
]]></description><link>https://forum.qt.io/post/566565</link><guid isPermaLink="true">https://forum.qt.io/post/566565</guid><dc:creator><![CDATA[Burkules]]></dc:creator><pubDate>Mon, 09 Dec 2019 20:20:57 GMT</pubDate></item><item><title><![CDATA[Reply to Failure Creating QOpenGLContext in Console Based Application on Mon, 09 Dec 2019 18:39:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">How are you writing your tests ?</p>
<p dir="auto">Are you creating at least a QGuiApplication in your tests ?</p>
]]></description><link>https://forum.qt.io/post/566549</link><guid isPermaLink="true">https://forum.qt.io/post/566549</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 09 Dec 2019 18:39:24 GMT</pubDate></item></channel></rss>