PDA

View Full Version : Qt program uses wrong video card



Koeienboei
5th August 2016, 05:37
Hey,

I've made an application using qt creator, but when I run the application in qt creator it crashes because it is using the wrong video card. When I run the application on it's own it does use the right video card.

I've selected in nvidia configuration screen to use higher end video card, but this doesn't work. Video card drivers are up to date. Reinstalling video drivers doesn't work.

Can someone help me with this plz? :)

ChrisW67
5th August 2016, 10:05
I run the application in qt creator it crashes because it is using the wrong video card.
On what evidence do you base this assertion? What environment is Qt Creator providing the child process? What cards? What OS? Which Qt version? Which Qt features are you using?

Koeienboei
5th August 2016, 12:09
I use the function: glGetString(GL_VERSION)

I find out it is using my intel GPU and not my nvidia GPU. (geforce gt540m)

The intel card supports opengl 3.0 and the nvidia card supports 3.3. Im using functions for opengl 3.3, this is why it crashes.

Im running it on windows 10, qt version 5.6. The program is the begin of a game, it shows a character on the screen using the opengl functions of qt.

ChrisW67
6th August 2016, 07:54
Do you have the option to start a program using a particular GPU? On my laptop this is in the right-click context menu. If so, try running Qt Creator by explicitly selecting the nVidia card and then see if, when Creator launches your program it still has the wrong GPU.

Koeienboei
6th August 2016, 11:51
Im sorry I can't find it. Could you be more specific where this menu is?

d_stranz
6th August 2016, 16:30
On my laptop this is in the right-click context menu.

Might depend on how you've configured your graphics drivers. I have Nvidia's Nsight HUD ("Heads up display") installed, and the right-click menu gives me the option of starting under that (but nothing else graphics-related).

8Observer8
12th June 2020, 10:31
You can active your Geforce/Radeon video by adding this code:



#ifdef _WIN32
#include <windows.h>
extern "C" __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
#endif

#include "widget.h"

#include <QApplication>

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_UseDesktopOp enGL);
QApplication a(argc, argv);

Widget w;
w.show();

return a.exec();
}