Apr 29, 2015 at 4:17am UTC
I'm getting error ISO C++ declaration of 'render' with no type [-fpermissive] and I don't know why....
I'm sorry this is so long but
-------------My render.h file-------------------------------------------
#ifndef RENDER_H
#define RENDER_H
#include "tonkboard.h"
#include "base.h"
#include "card.h"
#include "base.h"
#include "tonk.h"
#include "home.h"
#include "tonkplayer.h"
#include <QMenuBar>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QString>
#include <iostream>
class Render : public QBaseWidget
{
Q_OBJECT
public:
Render();
Render(QStackedWidget* stackedWidget,QWidget *parent = 0);
~Render()
{
}
public slots:
void make();
private:
vector<TonkPlayer*> players;
QVBoxLayout *layout;
};
#endif // RENDER_H
-----------and render.cpp:--------------------------------------------
#include "render.h"
#include "tonkboard.h"
#include "base.h"
#include "card.h"
#include "base.h"
#include "tonk.h"
#include "home.h"
#include "tonkplayer.h"
#include <QMenuBar>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QString>
#include <iostream>
using namespace std;
Render::render(QStackedWidget* stackedWidget,QWidget *parent)
:QBaseWidget(parent)
{
BaseStackwidget = stackedWidget;
players = vector<TonkPlayer*> (4);
layout = new QVBoxLayout();
setLayout(layout);
}
void Render::make()
{
// if (layout->children().size() != 0)
// {
// QLayoutItem *item;
// while ((item = layout->takeAt(0)) != 0)
// {
// cout << "removing" << endl;
// layout->removeItem(item);
// }
// }
for(int i = 0; i < this->players.size(); i++)
{
cout << "loop" << endl;
QVBoxLayout* sub = new QVBoxLayout();
cout << "check" << endl;
TonkPlayer* temp = this->players.at(i);
cout << "check2" << endl;
sub->addWidget(new QLabel(QString::fromStdString(temp->name)));
cout << "check3" << endl;
if(temp->spreads.size() > 0) // > 0
{
cout << "loop2" << endl;
sub->addWidget(new QLabel("Spreads: "));
for(int j = 0; j < temp->spreads.size(); j++)
{
cout << "loop3" << endl;
sub->addWidget(new QLabel(QString::fromStdString(temp->spreads.at(i))));
cout << "widget for spreads" << endl;
}
}
else
{
cout << "loop else" << endl;
sub->addWidget(new QLabel("No spreads yet!"));
cout << "widget indicating that there are no spreads" << endl;
}
sub->addWidget(new QLabel(QString::fromStdString("Hand: "+temp->printHand())));
cout << "widget for players hand" << endl;
layout->addLayout(sub);
}
//setLayout(layout);
layout->update();
}
------------ I want to call make to show the widgets in my GUI here in tonkboard.cpp: ------------------------------------------------------
#include "tonkboard.h"
#include "base.h"
#include "card.h"
#include "base.h"
#include "tonk.h"
#include "home.h"
#include "tonkplayer.h"
#include <QMenuBar>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QString>
#include <iostream>
#include "render.h"
using namespace std;
TonkBoard::TonkBoard(QStackedWidget* stackedWidget,QWidget *parent)
:QBaseWidget(parent)
{
BaseStackwidget = stackedWidget;
players = vector<TonkPlayer*> (4);
createMenus();
layout = new QVBoxLayout();
setLayout(layout);
back = new QPushButton("Go Back");
layout->addWidget(back);
QObject::connect(back,SIGNAL(clicked()),this, SLOT(GoBack()));
cout << "go back button added" << endl;
}
void TonkBoard::createTonkBoard()
{
//go to game Tonk
TonkBoard *tonkboard = new TonkBoard(BaseStackwidget);
BaseStackwidget->addWidget(tonkboard);
BaseStackwidget->setCurrentWidget(tonkboard);
cout << "render started" << endl;
this->make();
cout << "render finished" << endl;
}
void TonkBoard::initPlayers(int count)
{
this->players.clear();
for(int i = 0; i < count; i++)
{
players.push_back(new TonkPlayer(count,"Player "+count));
cout << "initPlayers" << endl;
}
}
void TonkBoard::createTwoPlayer()
{
this->initPlayers(2);
cout << "2 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::createThreePlayer()
{
this->initPlayers(3);
cout << "3 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::createFourPlayer()
{
this->initPlayers(4);
cout << "4 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::GoBack()
{
//go back to Tonk config
Tonk *tonk= new Tonk(BaseStackwidget);
BaseStackwidget->addWidget(tonk);
BaseStackwidget->setCurrentWidget(tonk);
cout << " " << endl;
cout << "went back to TONK configuration" << endl;
}
void TonkBoard::createMenus()
{
menuBar = new QMenuBar();
}
QMenuBar* TonkBoard::GetMenuBar() const
{
return menuBar;
}
Last edited on Apr 29, 2015 at 4:25am UTC
Apr 29, 2015 at 4:26am UTC
Render::r ender(QStackedWidget* stackedWidget,QWidget *parent)
The underlined letter should be capital.
Apr 29, 2015 at 4:27am UTC
LOL...
you are a god among men
Apr 29, 2015 at 1:53pm UTC
Error now is '((TonkBoard*)this)->QWidget::render' does not have class type
-------tonkboard.cpp------------------------------------------------------------------------------------------
#include "tonkboard.h"
#include "base.h"
#include "card.h"
#include "base.h"
#include "tonk.h"
#include "home.h"
#include "tonkplayer.h"
#include <QMenuBar>
#include <QVBoxLayout>
#include <QTextEdit>
#include <QString>
#include <iostream>
#include "render.h"
using namespace std;
TonkBoard::TonkBoard(QStackedWidget* stackedWidget,QWidget *parent)
:QBaseWidget(parent)
{
BaseStackwidget = stackedWidget;
players = vector<TonkPlayer*> (4);
createMenus();
layout = new QVBoxLayout();
setLayout(layout);
back = new QPushButton("Go Back");
layout->addWidget(back);
QObject::connect(back,SIGNAL(clicked()),this, SLOT(GoBack()));
cout << "go back button added" << endl;
}
void TonkBoard::createTonkBoard()
{
//go to game Tonk
TonkBoard *tonkboard = new TonkBoard(BaseStackwidget);
BaseStackwidget->addWidget(tonkboard);
BaseStackwidget->setCurrentWidget(tonkboard);
this->render.make();
//cout << "render started" << endl;
//this->render();
//cout << "render finished" << endl;
}
void TonkBoard::initPlayers(int count)
{
this->players.clear();
for(int i = 0; i < count; i++)
{
players.push_back(new TonkPlayer(count,"Player "+count));
cout << "initPlayers" << endl;
}
}
void TonkBoard::createTwoPlayer()
{
this->initPlayers(2);
cout << "2 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::createThreePlayer()
{
this->initPlayers(3);
cout << "3 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::createFourPlayer()
{
this->initPlayers(4);
cout << "4 Players" << endl;
this->createTonkBoard();
}
void TonkBoard::GoBack()
{
//go back to Tonk config
Tonk *tonk= new Tonk(BaseStackwidget);
BaseStackwidget->addWidget(tonk);
BaseStackwidget->setCurrentWidget(tonk);
cout << " " << endl;
cout << "went back to TONK configuration" << endl;
}
void TonkBoard::createMenus()
{
menuBar = new QMenuBar();
}
QMenuBar* TonkBoard::GetMenuBar() const
{
return menuBar;
}
Last edited on Apr 29, 2015 at 2:03pm UTC
Apr 29, 2015 at 2:02pm UTC
I also tried:
Render *make= new Render(BaseStackwidget);
BaseStackwidget->addWidget(make);
BaseStackwidget->setCurrentWidget(make);
in place of the this->render.make(); line
Apr 30, 2015 at 4:42am UTC
render is a function, not an object with a make method.