📄 linkform.cpp~
字号:
/****************************************************************************** Form implementation generated from reading ui file 'linkForm.ui'**** Created by: The User Interface Compiler ($Id: qt/main.cpp 3.3.8 edited Jan 11 14:47 $)**** WARNING! All changes made in this file will be lost!****************************************************************************/#include "linkForm.h"#include <qvariant.h>#include <qlabel.h>#include <qpushbutton.h>#include <qlineedit.h>#include <qlayout.h>#include <qtooltip.h>#include <qwhatsthis.h>#include <qimage.h>#include <qpixmap.h>/* * Constructs a linkform as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */linkform::linkform( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ),s(){ if ( !name ) setName( "linkform" ); iptable = new QLabel( this, "iptable" ); iptable->setGeometry( QRect( 20, 20, 20, 31 ) ); portlable = new QLabel( this, "portlable" ); portlable->setGeometry( QRect( 210, 20, 40, 31 ) ); linkBtn = new QPushButton( this, "linkBtn" ); linkBtn->setGeometry( QRect( 140, 91, 51, 37 ) ); quitBtn = new QPushButton( this, "quitBtn" ); quitBtn->setGeometry( QRect( 250, 91, 61, 37 ) ); resetBtn = new QPushButton( this, "resetBtn" ); resetBtn->setGeometry( QRect( 20, 91, 60, 37 ) ); ipTxt = new QLineEdit( this, "ipTxt" ); ipTxt->setGeometry( QRect( 47, 20, 111, 28 ) ); portTxt = new QLineEdit( this, "portTxt" ); portTxt->setGeometry( QRect( 249, 20, 41, 28 ) ); languageChange(); resize( QSize(347, 164).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); str_ip=""; str_port=""; // signals and slots connections connect( resetBtn, SIGNAL( clicked() ), ipTxt, SLOT( clear() ) ); connect( resetBtn, SIGNAL( clicked() ), portTxt, SLOT( clear() ) ); connect( resetBtn, SIGNAL( clicked() ), ipTxt, SLOT( setFocus() ) ); connect( quitBtn, SIGNAL( clicked() ), this, SLOT( close() ) ); connect( linkBtn, SIGNAL( clicked() ), this, SLOT( GetTxt() ) ); connect( this, SIGNAL( toSetIP() ), this, SLOT( SetIP() ) ); connect( this, SIGNAL( toSetSocket() ), this, SLOT( SetSocket() ) ); connect( this, SIGNAL( toGetMsg() ), this, SLOT( GetSerMsg() ) ); connect( this, SIGNAL( retry() ), ipTxt, SLOT( clear() ) ); connect( this, SIGNAL( retry() ), portTxt, SLOT( clear() ) ); connect( this, SIGNAL( retry() ), ipTxt, SLOT( setFocus() ) ); // tab order setTabOrder( ipTxt, portTxt ); setTabOrder( portTxt, resetBtn ); setTabOrder( resetBtn, linkBtn ); setTabOrder( linkBtn, quitBtn );}/* * Destroys the object and frees any allocated resources */linkform::~linkform(){ // no need to delete child widgets, Qt does it all for us}/* * Sets the strings of the subwidgets using the current * language. */void linkform::languageChange(){ setCaption( tr( "Link to server" ) ); iptable->setText( tr( "IP :" ) ); portlable->setText( tr( "Port :" ) ); linkBtn->setText( tr( "&Link" ) ); linkBtn->setAccel( QKeySequence( tr( "Alt+L" ) ) ); quitBtn->setText( tr( "&Quit" ) ); quitBtn->setAccel( QKeySequence( tr( "Alt+Q" ) ) ); resetBtn->setText( tr( "&Reset" ) ); resetBtn->setAccel( QKeySequence( tr( "Alt+R" ) ) );}void linkform::GetTxt(){ str_ip=ipTxt-> text(); str_port=portTxt-> text(); emit toSetIP();}void linkform::SetIP(){ if(s.GetIP(str_ip)) { emit toSetSocket(); }}int linkform::SetSocket(){ int i; i=s.SetSocket(); switch(i) { case 1: { QMessageBox::information( this, "Link", "Get host by name error!\n" "Retry!" ); emit retry(); return 0; }break; case 2: { QMessageBox::information( this, "Link Server", "Set Socket error!\n" "Please Retry!" ); }break; case 3: { QMessageBox::information( this, "Link Server", "Set Socket error!\n" "Server has not been lanuched!" ); }break; default: { emit toGetMsg(); } } return 0;}void linkform::GetSerMsg(){ char* msg=s.GetMsg(); if((strncmp(msg,"connect ok",10))==0) { flogin=new loginForm(s); cout<<"To goto Login Form"<<endl; flogin->show(); //sleep(1); cout<<"Close linkform"<<endl; this->close(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -