I have the same problem as ahmadka. When I try to access any such variable "aktualnyGracz" or another variable within this function, the program crashes.
In the constructor variables are displayed good.
This is my code:
server.h
{
Q_OBJECT
public:
...
Table *zwrocTable()
{ return table; }
QList<Gracz *> listaGracz;
qint16 naszIndex;
...
public slots:
...
void startGame();
...
private:
Table *table;
};
class Server : public QObject
{
Q_OBJECT
public:
...
Table *zwrocTable()
{ return table; }
QList<Gracz *> listaGracz;
qint16 naszIndex;
...
public slots:
...
void startGame();
...
private:
QWidget *parentWindow;
Table *table;
};
To copy to clipboard, switch view to plain text mode
server.cpp
void Server::startGame()
{
table = new Table(parentWindow, listaGracz, naszIndex);
connect(table, SIGNAL(closeTable()), this, SLOT(closeServer()), Qt::DirectConnection);
connect(table, SIGNAL(podbij(quint16)), this, SLOT(podbij(quint16)), Qt::DirectConnection);
connect(table, SIGNAL(spasuj()), this, SLOT(spasuj()));
table->ustawGracza(0);
}
void Server::startGame()
{
table = new Table(parentWindow, listaGracz, naszIndex);
connect(table, SIGNAL(closeTable()), this, SLOT(closeServer()), Qt::DirectConnection);
connect(table, SIGNAL(podbij(quint16)), this, SLOT(podbij(quint16)), Qt::DirectConnection);
connect(table, SIGNAL(spasuj()), this, SLOT(spasuj()));
table->ustawGracza(0);
}
To copy to clipboard, switch view to plain text mode
table.h
class Table
: public QMainWindow,
public Ui
::TableWindow{
Q_OBJECT
public:
Table
(QWidget *parent, QList<Gracz
*>
&l, qint16
&n
);
void ustawGracza(qint16 index);
private:
...
qint16 naszIndex;
QList<Gracz *> listaWskaz;
};
class Table : public QMainWindow, public Ui::TableWindow
{
Q_OBJECT
public:
Table(QWidget *parent, QList<Gracz *> &l, qint16 &n);
void ustawGracza(qint16 index);
private:
...
qint16 naszIndex;
QList<Gracz *> listaWskaz;
};
To copy to clipboard, switch view to plain text mode
table.cpp
Table
::Table(QWidget *parent, QList<Gracz
*>
&l, qint16
&n
) : {}
void Table::ustawGracza(qint16 index)
{
qDebug() << "something " << index;
qDebug() << aktualnyGracz;
uaktualnij();
}
Table::Table(QWidget *parent, QList<Gracz *> &l, qint16 &n) :
QMainWindow(parent), listaWskaz(l), naszIndex(n)
{}
void Table::ustawGracza(qint16 index)
{
qDebug() << "something " << index;
qDebug() << aktualnyGracz;
uaktualnij();
}
To copy to clipboard, switch view to plain text mode
Can you help me?
Bookmarks