Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Polish
  4. QObject::connect: No such slot myclass::start_load_game(); in ../mc2d/myclass.cpp:40 QObject::connect: No such slot myclass::start_new_game(); in ../mc2d/myclass.cpp:41
Forum Updated to NodeBB v4.3 + New Features

QObject::connect: No such slot myclass::start_load_game(); in ../mc2d/myclass.cpp:40 QObject::connect: No such slot myclass::start_new_game(); in ../mc2d/myclass.cpp:41

Scheduled Pinned Locked Moved Solved Polish
2 Posts 2 Posters 893 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.
  • Y Offline
    Y Offline
    YoungProgrammer
    wrote on last edited by
    #1

    Mam pewien problem. Nie wiem dlaczego nie wykrywa mi slotów z mojej klasy.
    plik myclass.cpp

    #include"game.h"
    #include"exgame.h"
    #include"myclass.h"
    #include<QGraphicsPixmapItem>
    #include<QMouseEvent>
    #include<QObject>
    #include <QKeyEvent>
    #include<QCoreApplication>
    
    void myclass::start_new_game()
    {
        new_game->setGeometry(QRect(QPoint(0,-100),QSize(180, 90)));
        newgame=0;
        started=1;
        qDebug()<<"New game";
        all = new game (newgame, "testsave");
        all->load_scene();
        view->setScene(all->return_scene());
    }
    
    void myclass::start_load_game()
    {
        load_game->setGeometry(QRect(QPoint(0,100),QSize(180, 90)));
        newgame=1;
        started=1;
        qDebug()<<"Load game";
        all = new game (newgame, "testsave");
        all->load_scene();
        view->setScene(all->return_scene());
    }
    
    myclass::myclass()
    {
        load_game = new QPushButton("Load game");
        new_game= new QPushButton("New game");
        load_game->setGeometry(QRect(QPoint(0,100),QSize(200, 100)));
        new_game->setGeometry(QRect(QPoint(0,-100),QSize(200, 100)));
        all->return_scene()->addWidget(load_game);
        all->return_scene()->addWidget(new_game);
        connect(load_game, SIGNAL (released()), this, SLOT (start_load_game();));
        connect(new_game, SIGNAL (released()), this, SLOT (start_new_game();));
    }
    
    

    plik myclass.h

    #include"game.h"
    #include<QPushButton>
    #include<QGraphicsPixmapItem>
    #include<QObject>
    #include <QKeyEvent>
    
    #ifndef MYCLASS_H
    #define MYCLASS_H
    
    class myclass: public QObject, public QGraphicsPixmapItem{
        Q_OBJECT
        QPushButton *new_game;
        QPushButton *load_game;
    public slots:
        void start_new_game ();
        void start_load_game ();
    public:
        myclass ();
    };
    #endif // MYCLASS_H
    
    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, don't use semicolons in connect(), try change to

      connect(load_game, SIGNAL (released()), this, SLOT (start_load_game()));
      connect(new_game, SIGNAL (released()), this, SLOT (start_new_game()));
      
      1 Reply Last reply
      2

      • Login

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