23,121
社区成员
发帖
与我相关
我的任务
分享
VPN_load::VPN_load(QMainWindow *parent)
: QMainWindow(parent)
{
setupUi(this);
//bool op;
//lineEdit_account->installEventFilter(this);
//lineEdit_password->installEventFilter(this);
//op=lineEdit_account->isVisibleTo ( this);
//op=lineEdit_password->isVisibleTo ( this);
lineEdit_password->setEchoMode ( QLineEdit::Password );
pushButton_configure->setCursor ( Qt::PointingHandCursor);
pushButton_cancel->setCursor ( Qt::PointingHandCursor);
connect(&server_a, SIGNAL(show_man()), &usr, SLOT(show_man_acc())); //把server_a界面的信号跟show_man_acc()这个slot绑定
connect(pushButton_configure, SIGNAL(clicked()), this, SLOT(check_load()));
connect(pushButton_cancel, SIGNAL(clicked()), this, SLOT(cancel_line()));
QFile file("last_load.txt");
QChar c;
char buf[200];
qint64 read_bytes;;
if(!file.open(QIODevice::ReadWrite))
QMessageBox::information( this, "debug", "Fail to open last load file!" );
read_bytes=file.readLine(buf,200);
cout<<"read acc:"<<read_bytes<<"bytes"<<endl;
last_acc="";
last_acc.append(buf);
//last_acc.remove(read_bytes-1,read_bytes-1);
file.close();
lineEdit_account->setText ( last_acc );
}
void VPN_load::show_man_acc()
{
printf("load getsignal to show man_acc.\n");
man_access.show(); //这里show出man_access
}
class VPN_load : public QMainWindow, public Ui::MainWindow_load
{
Q_OBJECT
public:
VPN_load(QMainWindow *parent = 0);
~VPN_load();
man_usr man_access;
void keyPressEvent( QKeyEvent * event); //for key enter
void showEvent ( QShowEvent * event );
void hideEvent ( QHideEvent * event );
//bool eventFilter(QObject *target,QEvent *event);
private:
VPN_usr usr; //这里2个子界面
server server_a;
QString last_acc;
private slots:
int check_load();
void cancel_line();
void show_man_acc();
};
/************main.cpp ****************//
//这里主界面就是VPN_load *dialog_load
//#include "ui_VPN.h"
#include <QApplication>
#include "vpn_usr.h"
#include "vpn_load.h"
//#include <QDialog>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//VPN_usr *dialog = new VPN_usr;
VPN_load *dialog_load = new VPN_load;
//QDialog *dialog = new QDialog;
dialog_load->show();
return app.exec();
}