ahoj,mensi problem,ve tride mam 5 dynamicky vytvorenych tlacitek v konstruktoru a kdyz stisknu tlacitko nejake tak k nim chci ve slotu pristupovat,ale vyhodi to chybu jako by pamet vubec nebyla alokovana.
gui.cpp:
gui::gui (mujserver * server)
{
QLabel * popisekAdresa=new QLabel ("adresa");
QLabel * popisekPort=new QLabel ("port");
QLabel * popisekZprava=new QLabel ("zprava");
QString textZpravy,adresa;
QPushButton * kickClient=new QPushButton ("vykopnout klienta");
QPushButton *kickAllClients=new QPushButton ("vykopnout vsechny klienty");
QPushButton *sendMsg=new QPushButton ("posli zpravu");
QPushButton *startServer=new QPushButton ("nastartovat");
QPushButton *stopServer=new QPushButton ("stop");
QPushButton * nastavit=new QPushButton ("nastavit");
QHBoxLayout *layout=new QHBoxLayout ();
QHBoxLayout * layout2=new QHBoxLayout ();
QVBoxLayout * Vlayout=new QVBoxLayout ();
QComboBox * listClients=new QComboBox ();
QLineEdit * adresaEdit=new QLineEdit ();
QLineEdit *portEdit=new QLineEdit ();
QLineEdit *zpravaEdit=new QLineEdit ();
QWidget * widget=new QWidget (this);
QWidget * widget2=new QWidget (this);
this->server=server;
startServer->setEnabled (false);
stopServer->setEnabled (false);
//sendMsg->setEnabled (false);
kickClient->setEnabled (false);
kickAllClients->setEnabled (false);
layout->addWidget (kickClient);
layout->addWidget (kickAllClients);
layout->addWidget (sendMsg);
layout->addWidget (startServer);
layout->addWidget (stopServer);
layout->addWidget (listClients);
layout2->addWidget (popisekAdresa);
layout2->addWidget (adresaEdit);
layout2->addWidget (popisekPort);
layout2->addWidget (portEdit);
layout2->addWidget (popisekZprava);
layout2->addWidget (zpravaEdit);
layout2->addWidget (nastavit);
widget->setLayout (layout);
widget2->setLayout (layout2);
Vlayout->addWidget (widget);
Vlayout->addWidget (widget2);
this->setLayout (Vlayout);
connect (startServer,SIGNAL (clicked ()),this,SLOT (start()));
connect (stopServer,SIGNAL (clicked ()),this,SLOT (stop()));
connect (kickClient,SIGNAL (clicked ()),this,SLOT (kick()));
connect (kickAllClients,SIGNAL (clicked ()),this,SLOT (KickAll()));
connect (sendMsg,SIGNAL (clicked ()),this,SLOT (send()));
connect (nastavit,SIGNAL (clicked()),this,SLOT (nastav()));
show ();
}
void gui::start ()
{
server->start ();
}
void gui::stop ()
{
server->stop ();
}
void gui::kick ()
{
}
void gui::KickAll ()
{
server->KickAll ();
}
void gui::send ()
{
QString text=zpravaEdit->text ();
server->send (text);
}
void gui::SendAll ()
{
}
void gui::nastav ()
{
adresa=adresaEdit->text ();
QString portS=portEdit->text ();
port=portS.toInt ();
startServer->setEnabled (true);
stopServer->setEnabled (true);
sendMsg->setEnabled (true);
kickClient->setEnabled (true);
kickAllClients->setEnabled (true);
}
gui.h
#ifndef GUI
#define GUI
#include "header.h"
#include "mujserver.h"
class gui:public QWidget
{
Q_OBJECT
private:
int port;
QString textZpravy,adresa;
QWidget *widget,*widget2;
QComboBox * listClients;
QPushButton * kickClient,*kickAllClients,*sendMsg,*startServer,*stopServer,*nastavit;
QHBoxLayout * layout,*layout2;
QVBoxLayout * Vlayout;
QTextBrowser * stavovyText;
QLineEdit * adresaEdit,*portEdit,*zpravaEdit;
mujserver * server;
QLabel *popisekAdresa,*popisekPort,*popisekZprava;
public:
gui (mujserver * server);
private slots:
void stop ();
void start ();
void KickAll();
void kick ();
void send ();
void SendAll ();
void nastav ();
};
#endif GUI
poradte prosim cim to je,uz si s tim nevim rady. vzdyt pamet sem prece alokoval.