Ahoj,soucasti meho serveru v QT je jednoduche gui,prvky jsou dany do horizontalniho layoutu,obsah kazdeho layoutu se vlozi na samostatny widget ,ty se pridaji do vertikalniho layoutu a ten se nasledne nestavi jako hlavni layout pro cele okno. vysledkem je okno co ma 2 polozky vertikalne a 5 horizontalne. proc do jde jenom tak slozite netusim. ale k problemu.. ono to nefunguje. vsechno funguje jak ma,vytvorim polozky,vlozim do layoutu ale pri pokusu dat obsah layoutu na widget ( aby byl samostatny widget na jeden radek) to spadne. prikladam kod.
gui.cpp :
#include "gui.h"
gui::gui ()
{
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");
QHBoxLayout *layout=new QHBoxLayout ();
QHBoxLayout * layout2=new QHBoxLayout ();
QVBoxLayout * Vlayout=new QVBoxLayout ();
QComboBox * listClients=new QComboBox ();
QLineEdit * adresaEdit=new QLineEdit ();
QLineEdit *portEdit=new QLineEdit ();
QWidget * widget=new QWidget (this);
QWidget * widget2=new QWidget (this);
widget->show ();
layout->addWidget (kickClient);
layout->addWidget (kickAllClients);
layout->addWidget (sendMsg);
layout->addWidget (startServer);
layout->addWidget (stopServer);
layout->addWidget (listClients);
layout2->addWidget (adresaEdit);
layout2->addWidget (portEdit);
layout2->addWidget (nastavit);
widget->setLayout (layout);
widget2->setLayout (layout2);
Vlayout->addWidget (widget);
Vlayout->addWidget (widget2);
this->setLayout (Vlayout);
show ();
}
gui.h :
#ifndef GUI
#define GUI
#include "header.h"
class gui:public QWidget
{
Q_OBJECT
private:
QWidget *widget,*widget2;
QComboBox * listClients;
QPushButton * kickClient,*kickAllClients,*sendMsg,*startServer,*stopServer,*nastavit;
QHBoxLayout * layout,*layout2;
QVBoxLayout * Vlayout;
QTextBrowser * stavovyText;
QLineEdit * adresaEdit,*portEdit;
public:
gui ();
};
#endif GUI
header.h :
#ifndef HEADER
#define HEADER
#include <QtWidgets\qlineedit.h>
#include <QtNetwork\qtcpserver.h>
#include <QtNetwork\qtcpsocket.h>
#include <QtWidgets\qapplication.h>
#include <QtCore\qmap.h>
#include <QtCore\qbytearray.h>
#include <QtNetwork\qhostaddress.h>
#include <QtCore\qdatastream.h>
#include <QtCore\qtextstream.h>
#include <QtCore\qfile.h>
#include <QtWidgets\qpushbutton.h>
#include <qtwidgets\qlayout.h>
#include <QtWidgets\qcombobox.h>
#include <QtWidgets\qtextbrowser.h>
#include "gui.h"
#endif HEADER
na zaver se chcu zeptat,lze to udelat lip? prehledl sem nejakou mnohem snadnejsi a rychlejsi moznost? dekuju za odpovedi.