diff --git a/src/platformsupport/glxconvenience/qglxconvenience.cpp b/src/platformsupport/glxconvenience/qglxconvenience.cpp
index d7cc36627ac..b719b2092ef 100644
--- a/src/platformsupport/glxconvenience/qglxconvenience.cpp
+++ b/src/platformsupport/glxconvenience/qglxconvenience.cpp
@@ -211,6 +211,8 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
         const int requestedGreen = qMax(0, format.greenBufferSize());
         const int requestedBlue = qMax(0, format.blueBufferSize());
         const int requestedAlpha = qMax(0, format.alphaBufferSize());
+        const int requestedSampleBuffers = (format.samples() > 0) ? 1 : format.samples();
+        const int requestedSamples = format.samples();
 
         GLXFBConfig compatibleCandidate = nullptr;
         for (int i = 0; i < confcount; i++) {
@@ -227,9 +229,18 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
             if (visual.isNull())
                 continue;
 
+            if (requestedSampleBuffers >= 0) {
+                int actualSampleBuffers;
+                glXGetFBConfigAttrib(display, config, GLX_SAMPLE_BUFFERS_ARB, &actualSampleBuffers);
+                if (requestedSampleBuffers != actualSampleBuffers)
+                    continue;
+            }
+
             const int actualRed = qPopulationCount(visual->red_mask);
             const int actualGreen = qPopulationCount(visual->green_mask);
             const int actualBlue = qPopulationCount(visual->blue_mask);
+            int actualSamples;
+            glXGetFBConfigAttrib(display, candidate, GLX_SAMPLES_ARB, &actualSamples);
             const int actualAlpha = visual->depth - actualRed - actualGreen - actualBlue;
 
             if (requestedRed && actualRed < requestedRed)
@@ -240,6 +251,8 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
                 continue;
             if (requestedAlpha && actualAlpha < requestedAlpha)
                 continue;
+            if (requestedSamples > 0 && actualSamples < requestedSamples)
+                continue;
             compatibleCandidate = candidate;
 
             if (requestedRed && actualRed != requestedRed)
@@ -250,11 +263,13 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , QSurfaceFormat format
                 continue;
             if (requestedAlpha && actualAlpha != requestedAlpha)
                 continue;
+            if (requestedSamples >= 0 && actualSamples != requestedSamples)
+                continue;
 
             return candidate;
         }
         if (compatibleCandidate) {
-            qCDebug(lcGlx) << "qglx_findConfig: Found non-matching but compatible FBConfig";
+            qCDebug(lcGlx, "qglx_findConfig: Found non-matching but compatible FBConfig for (%d %d %d %d)", requestedRed, requestedGreen, requestedBlue, requestedAlpha);
             return compatibleCandidate;
         }
         qCWarning(lcGlx, "qglx_findConfig: Failed to finding matching FBConfig (%d %d %d %d)", requestedRed, requestedGreen, requestedBlue, requestedAlpha);
@@ -311,7 +326,7 @@ void qglx_surfaceFormatFromGLXFBConfig(QSurfaceFormat *format, Display *display,
     glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE,   &alphaSize);
     glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE,   &depthSize);
     glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
-    glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB,  &sampleBuffers);
+    glXGetFBConfigAttrib(display, config, GLX_SAMPLE_BUFFERS_ARB,  &sampleBuffers);
     glXGetFBConfigAttrib(display, config, GLX_STEREO,       &stereo);
     if (flags & QGLX_SUPPORTS_SRGB)
         glXGetFBConfigAttrib(display, config, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable);
@@ -350,7 +365,7 @@ void qglx_surfaceFormatFromVisualInfo(QSurfaceFormat *format, Display *display,
     glXGetConfig(display, visualInfo, GLX_ALPHA_SIZE,   &alphaSize);
     glXGetConfig(display, visualInfo, GLX_DEPTH_SIZE,   &depthSize);
     glXGetConfig(display, visualInfo, GLX_STENCIL_SIZE, &stencilSize);
-    glXGetConfig(display, visualInfo, GLX_SAMPLES_ARB,  &sampleBuffers);
+    glXGetConfig(display, visualInfo, GLX_SAMPLE_BUFFERS_ARB,  &sampleBuffers);
     glXGetConfig(display, visualInfo, GLX_STEREO,       &stereo);
     if (flags & QGLX_SUPPORTS_SRGB)
         glXGetConfig(display, visualInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB, &srgbCapable);
