Originally Posted by
Santosh Reddy
layout.addWidget(txt); //<<<< remove '&'
layout.addWidget(txt); //<<<< remove '&'
To copy to clipboard, switch view to plain text mode
Thanks a lot, you have been a great help Well of course I continued the project and came quiet far. I will attach a little screenshot from the program so far party.jpg
Sadly I still got some little problems I can't figure out.
I'm currently trying to make the "Run" button work. I'm getting this error: cannot call member function 'int structs::getRun()' without object // and setRun()
structs.h:
#ifndef STRUCTS_H
#define STRUCTS_H
class structs
{
public:
structs();
void setRun(int i);
int getRun();
private:
int isRun = 0;
};
#endif // STRUCTS_H
#ifndef STRUCTS_H
#define STRUCTS_H
class structs
{
public:
structs();
void setRun(int i);
int getRun();
private:
int isRun = 0;
};
#endif // STRUCTS_H
To copy to clipboard, switch view to plain text mode
structs.cpp
#include "structs.h"
/*struct::structs()
{
}*/
void structs::setRun(int i)
{
isRun = i;
}
int structs::getRun()
{
return isRun;
}
#include "structs.h"
/*struct::structs()
{
}*/
void structs::setRun(int i)
{
isRun = i;
}
int structs::getRun()
{
return isRun;
}
To copy to clipboard, switch view to plain text mode
I want to use them here:
berechnung.cpp (math)
if (structs::getRun() == 1) {
if (i == 7){
if (hypo >= 0){
if (richtung > 22.5 && richtung < 67.5 && _person->positionX < _person->vec1){
_person->positionX = _person->positionX + 1;
qDebug() << "I think I have just done a step to the RIGHT->!!!";
}
else if (richtung > 22.5 && richtung < 67.5 && _person->positionX > _person->vec1){
_person->positionX = _person->positionX - 1;
qDebug() << "I think I have just done a step to the <-LEFT!!!";
}
else if (richtung > 0 && richtung < 22.5 && _person->positionY > _person->vec2){
_person->positionX = _person->positionY - 1;
qDebug() << "I think I have just done a step to the TOP!!!";
}
else if (richtung > 0 && richtung < 22.5 && _person->positionY < _person->vec2){
_person->positionX = _person->positionY + 1;
qDebug() << "I think I have just done a step to the BOTTOM!!!";
}
}
richtung = 0;
}
structs::setRun(0);
}
berechnung.cpp (math)
if (structs::getRun() == 1) {
if (i == 7){
if (hypo >= 0){
if (richtung > 22.5 && richtung < 67.5 && _person->positionX < _person->vec1){
_person->positionX = _person->positionX + 1;
qDebug() << "I think I have just done a step to the RIGHT->!!!";
}
else if (richtung > 22.5 && richtung < 67.5 && _person->positionX > _person->vec1){
_person->positionX = _person->positionX - 1;
qDebug() << "I think I have just done a step to the <-LEFT!!!";
}
else if (richtung > 0 && richtung < 22.5 && _person->positionY > _person->vec2){
_person->positionX = _person->positionY - 1;
qDebug() << "I think I have just done a step to the TOP!!!";
}
else if (richtung > 0 && richtung < 22.5 && _person->positionY < _person->vec2){
_person->positionX = _person->positionY + 1;
qDebug() << "I think I have just done a step to the BOTTOM!!!";
}
}
richtung = 0;
}
structs::setRun(0);
}
To copy to clipboard, switch view to plain text mode
and here:
=display.cpp
void display::on_run_clicked()
{
structs::setRun(1);
qDebug() << "Congrats, you managed to click the Bottom: " << structs::getRun();
}
=display.cpp
void display::on_run_clicked()
{
structs::setRun(1);
qDebug() << "Congrats, you managed to click the Bottom: " << structs::getRun();
}
To copy to clipboard, switch view to plain text mode
Any idea how to make this work?
Bookmarks