<?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[Why are there two contexts instead of one?]]></title><description><![CDATA[<p dir="auto">I've been fighting a bug for some amount of time. I singled it out eventually, it was OpenGLContext related, but I still don't understand why this is happening.</p>
<p dir="auto">I was going to load my OpenGL textures later with a QAction trigger, instead of during initGL, but there was a context change in the middle for a reason unknown to me. I suppose I can set current context manually, but there's only a single OpenGLWidget instance in the entire program and I don't know why this is happening.</p>
<p dir="auto">Custom signal that fires at InitGL:</p>
<pre><code>ui.textureWidget-&gt;view()-&gt;sig_Start.connect([&amp;]() {
    cout &lt;&lt; "start" &lt;&lt; endl;
    cout &lt;&lt; QOpenGLContext::currentContext() &lt;&lt; endl;
    cout &lt;&lt; ui.textureWidget-&gt;view()-&gt;context() &lt;&lt; endl;
});
</code></pre>
<p dir="auto">QAction that is triggered later (much after initGL) on a key press:</p>
<pre><code>connect(action, &amp;QAction::triggered, [&amp;](bool) {
    cout &lt;&lt; "trigger" &lt;&lt; endl;
    cout &lt;&lt; QOpenGLContext::currentContext() &lt;&lt; endl;
    cout &lt;&lt; ui.textureWidget-&gt;view()-&gt;context() &lt;&lt; endl;
});
</code></pre>
<p dir="auto">Output:</p>
<pre><code>start
000002571DA62C00
000002571DA62C00
trigger
000002571EA88700 &lt;- ??
000002571DA62C00
</code></pre>
<p dir="auto">Why does this happen? The only OpenGLWidget I use is one wrapped in another widget added to a QMainWindow. Why is there a context change in the middle and what is that other context?</p>
]]></description><link>https://forum.qt.io/topic/134155/why-are-there-two-contexts-instead-of-one</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 08:39:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/134155.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Feb 2022 03:03:58 GMT</pubDate><ttl>60</ttl></channel></rss>