Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. Problema con Qt Creator
Qt 6.11 is out! See what's new in the release blog

Problema con Qt Creator

Scheduled Pinned Locked Moved Spanish
2 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Buenas veran necesito ayuda con este problema:
    Bueno la cosa es que para programar mi IDE favorito es QT Creator y estoy aprendiendo a usar SFML 2.1.
    Cree un proyecto y agrege las librerias escribi codigo y de hecho funciono perfectamente 100% compatibilidad con SFML :D.
    La cosa se puso fea al modularizar.
    Separe el codigo en un header llamado Game.h y el correspondiente codigo fuente Game.cpp
    Y el problema es que cuando construyo suelta que las variables que declare en el header Game.h no existe D:

    Aqui les doy el codigo para que tengan una mejor idea:
    Este es el Game.h
    @
    #ifndef GAME_H
    #define GAME_H
    #include <SFML/Graphics.hpp>
    #include <iostream>
    using namespace std;
    using namespace sf;

    class Game {

    private:
    RenderWindow ventana;
    Event evento;

    bool isPLay {true};
    bool presionar_A {false};
    bool click_izquierdo {false};
    

    private:
    void inicializar();
    void eventos();
    void update();
    void render();
    void clear();

    public:
    Game();
    void run();

    };

    #endif // GAME_H
    @

    Y este el Game.cpp:
    @
    #include "Game.h"
    #include <Game.h>
    #include <iostream>
    #include <SFML/Graphics.hpp>
    using namespace std;
    using namespace sf;

    Game::Game():ventana(VideoMode(800, 600),"Game") {

    }

    void Game::inicializar(){
    ventana.setFramerateLimit(60);
    ventana.setKeyRepeatEnabled(false);
    }

    void Game::eventos() {
    //Eventos
    while (ventana.pollEvent(evento)){

            if (evento.type == Event::Closed){
               isPlay = false;
            }
    
            if (evento.type == Event::KeyPressed && evento.key.code == Keyboard::A){
                presionar_A = true;
            }
            if (evento.type == Event::MouseButtonPressed && evento.key.code == Mouse::Left){
                click_izquierdo = true;
            }
        }
     }
    

    void Game::update() {

    if (presionar_A){
        cout << "Lol A :v" <<endl;
        presionar_A = false;
    }
    if (click_izquierdo){
        cout << "Lel click izquierdo :V" <<endl;
        click_izquierdo = false;
    }
    

    }

    void Game::render() {
    ventana.clear(Color::Blue);
    ventana.display();

    }

    void Game::clear(){
    ventana.close();
    }

    void run(){
    inicializar();

    while(isPlay){
    
        eventos();
        update();
        render();
    }
    clear();
    

    }
    @

    EL main:
    @
    #include "Game.h"
    #include <SFML/Graphics.hpp>
    #include <iostream>
    #include <memory>
    using namespace std;
    using namespace sf;

    int main (){
    shared_ptr<Game> Juego(new Game());
    Juego -> run();
    return 0;
    }
    @

    Notas:
    Soy novato xP
    Lo probe con qmake y cmake
    Tiene algo de codigo en c++ 11
    Funcionaba cuando tenia todo el codigo en el main.cpp

    Este es el error: https://cloud.openmailbox.org/public.php?service=files&t=ba7ce9ced755f5a2736e982829c23581

    Agradezco su ayuda

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hipersayan_x
      wrote on last edited by
      #2

      Linea 57 de Game.cpp, tiene que ser:

      @void Game::run()@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved