⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.ui.h

📁 这是一个在redhat9 linux系统中
💻 H
字号:
/****************************************************************************** ui.h extension file, included from the uic-generated form implementation.**** If you wish to add, delete or rename functions or slots use** Qt Designer which will update this file, preserving your code. Create an** init() function in place of a constructor, and a destroy() function in** place of a destructor.*****************************************************************************/#include <qstring.h>#include <qfile.h>#include <qtextstream.h>#include <qlineedit.h>#include <fstream.h>#include <stdio.h>#include <stdlib.h>bool flag=FALSE;QString GB_To_Utf8(char *strText){    return QString::fromLocal8Bit(strText);}void initgateway(QLineEdit *le, QPushButton * pb){    QFile file("/etc/sysconfig/network-scripts/ifcfg-eth0");    if(file.open(IO_ReadOnly))    {	QTextStream stream( &file );        QString line;        while ( !stream.eof() ) {            line = stream.readLine(); 	    if (line == "GATEWAY=192.168.0.254")	    {		le->setText(GB_To_Utf8(" ADSL"));		//le->setText("Now you used ADSL network");		pb->setText(GB_To_Utf8("切换至 校园网"));		//pb->setText( "Change to CAMPUS network");		flag = TRUE;	    }	    else if(line == "GATEWAY=192.168.0.1")	    {		le->setText(GB_To_Utf8("您现在使用的是 校园网"));		pb->setText(GB_To_Utf8("切换至 ADSL"));		//le->setText("Now you used CAMPUS network");		//pb->setText( "Change to ADSL network");		flag = TRUE;	    }        }        file.close();	if (!flag) {	   le->setText(GB_To_Utf8("您的网关不可用"));	   pb->setText(GB_To_Utf8("请您手动设置")); 	}    }}void Form1::init(){   initgateway(lineEdit3,pushButton4);}void Form1::ChangeGateway(){    FILE *fp;    fp = fopen("/tmp/ifcfg-eth0","w+");    fclose(fp);        QFile file1("/etc/sysconfig/network-scripts/ifcfg-eth0");    QFile file2("/tmp/ifcfg-eth0");    QTextStream stream1( &file1 );    QTextStream stream2( &file2 );    QString line;    if(file1.open(IO_ReadOnly) && file2.open(IO_ReadWrite))    {		                while ( !stream1.eof() ) {            line = stream1.readLine(); 	    	    	    	    if (line == "GATEWAY=192.168.0.254")	    {		stream2 <<"GATEWAY=192.168.0.1\n";	    }	    else if(line == "GATEWAY=192.168.0.1")	    {		stream2 <<"GATEWAY=192.168.0.254\n";			    }	    else stream2<<line<<"\n";        }       // file1.close();	//file2.close();	    }    else {lineEdit3->setText("Failed !!!"); return;}    //file1.close();    file1.close();    file2.close();    system("cp /tmp/ifcfg-eth0 /etc/sysconfig/network-scripts/ -f");    system("ifdown eth0");    system("ifup eth0");    system("rm /tmp/ifcfg-eth0 -f");    initgateway(lineEdit3,pushButton4);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -