Need help with declaration and constructor



  • I'm trying to use a constructor to declare something like

    timer = new QTimer(this);
    or
    camera = new QCamera(cameraInfo);

    but they all return as undeclared. What have I done wrong?
    I have include the required library in the header file, and I saw examples and other people sharing code with similar method of declaration. What have I done wrong?

    If I use the following declaration, it would work:

    QCamera camera;

    but I would like to use "setViewfinder", and it won't let me use it as camera.setViewfinder.
    and all the examplesI found are using
    camera->setViewfinder();


  • Moderators

    You need to post the relevant part of the compilation/linker output. Otherwise one needs a crystal ball.



  • @koahnig Sorry, still kinda new to this. I'm not sure if this is what you mean, but I do get a warning saying
    "'timer' was not declared in this scope." or "'camera' was not declared in this scope."


  • Moderators

    Assuming that you are using Qt creator as an IDE (Integrated Development Environment) there is the compilation output window. It should be listed "Compile output" on the button line of creator or in most cases it is already open. There you have the compiler and later also the linker output. That content is meant.
    Alternatively, you can open the window through "Windows"->"Output panes" and there should be listed "Compile output" as well.
    In case you are using a language different to English, it could be better to change to English because of naming. This should be possible under "Tools"->"Options"->"Environment" and "General"-tab.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.