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

📄 switchform.ui.h

📁 Linux下的qt编程示例
💻 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.*****************************************************************************/int L;QString Swi[128][3];void SwitchForm::init(){    int i, j;    QString str;    QDir::setCurrent("/root/FaultRecorder/");    QFile file( "switch_ratedvalue.DAT" );    file.open( IO_ReadOnly );    QTextStream stream( &file );    for ( i = 0; i < 128; i++ ){	for ( j = 0; j < 3; j++){	    stream>>Swi[i][j];	    if ( j==0 ){		switch_Table->setText(i, j, Swi[i][j]);	//显示开关名称;	    }	    if ( j==1 ){		if (Swi[i][j] == "1"){		    str = switch1RadioButton->text();		}else if (Swi[i][j] == "2"){		    str = switch2RadioButton->text();		}else if (Swi[i][j] == "3"){		    str = switch3RadioButton->text();		}else if (Swi[i][j] == "4"){		    str = switch4RadioButton->text();		}		switch_Table->setText(i, j, str);		//显示启动方式;	    }	    if ( j==2 ){		if (Swi[i][j] == "5"){		    str = switch5RadioButton->text();		}else if (Swi[i][j] == "6"){		    str = switch6RadioButton->text();		}else if (Swi[i][j] == "7"){		    str = switch7RadioButton->text();		}else if (Swi[i][j] == "8"){		    str = switch8RadioButton->text();		}else if (Swi[i][j] == "9"){		    str = switch9RadioButton->text();		}else if (Swi[i][j] == "10"){		    str = switch10RadioButton->text();		}else if (Swi[i][j] == "11"){		    str = switch11RadioButton->text();		}		switch_Table->setText(i, j, str);		//显示开关性质;	    }	}	str = "";    }    switch_Table->setColumnWidth(0,166);    switch_Table->setColumnWidth(1,70);    switch_Table->setColumnWidth(2,70);    LineEdit1->setEnabled(FALSE);    LineEdit2->setEnabled(FALSE);    switch1RadioButton->setEnabled(FALSE);    switch2RadioButton->setEnabled(FALSE);    switch3RadioButton->setEnabled(FALSE);    switch4RadioButton->setEnabled(FALSE);    switch5RadioButton->setEnabled(FALSE);    switch6RadioButton->setEnabled(FALSE);    switch7RadioButton->setEnabled(FALSE);    switch8RadioButton->setEnabled(FALSE);    switch9RadioButton->setEnabled(FALSE);    switch10RadioButton->setEnabled(FALSE);    switch11RadioButton->setEnabled(FALSE);    delPushButton->setEnabled(FALSE);    savePushButton->setEnabled(FALSE);        file.close();}//定值修改;void SwitchForm::edit(){    LineEdit2->setEnabled(TRUE);    switch1RadioButton->setEnabled(TRUE);    switch2RadioButton->setEnabled(TRUE);    switch3RadioButton->setEnabled(TRUE);    switch4RadioButton->setEnabled(TRUE);    switch5RadioButton->setEnabled(TRUE);    switch6RadioButton->setEnabled(TRUE);    switch7RadioButton->setEnabled(TRUE);    switch8RadioButton->setEnabled(TRUE);    switch9RadioButton->setEnabled(TRUE);    switch10RadioButton->setEnabled(TRUE);    switch11RadioButton->setEnabled(TRUE);    delPushButton->setEnabled(TRUE);    savePushButton->setEnabled(TRUE);    editPushButton->setEnabled(FALSE);}void SwitchForm::switch1RadioButton_edit(){    switch2RadioButton->setChecked(FALSE);    switch3RadioButton->setChecked(FALSE);    switch4RadioButton->setChecked(FALSE);}void SwitchForm::switch2RadioButton_edit(){    switch1RadioButton->setChecked(FALSE);    switch3RadioButton->setChecked(FALSE);    switch4RadioButton->setChecked(FALSE);}void SwitchForm::switch3RadioButton_edit(){    switch1RadioButton->setChecked(FALSE);    switch2RadioButton->setChecked(FALSE);    switch4RadioButton->setChecked(FALSE);}void SwitchForm::switch4RadioButton_edit(){    switch1RadioButton->setChecked(FALSE);    switch2RadioButton->setChecked(FALSE);    switch3RadioButton->setChecked(FALSE);}void SwitchForm::switch5RadioButton_edit(){    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch6RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch7RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch8RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch9RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch10RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);}void SwitchForm::switch11RadioButton_edit(){    switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);}void SwitchForm::switchTable(){    QString str;    L = switch_Table->currentRow();    LineEdit2->setText(Swi[L][0]);    if ( Swi[L][1] == "1" ){	switch1RadioButton->setChecked(TRUE);	switch2RadioButton->setChecked(FALSE);	switch3RadioButton->setChecked(FALSE);	switch4RadioButton->setChecked(FALSE);    }else if ( Swi[L][1] == "2" ){	switch1RadioButton->setChecked(FALSE);	switch2RadioButton->setChecked(TRUE);	switch3RadioButton->setChecked(FALSE);	switch4RadioButton->setChecked(FALSE);    }else if ( Swi[L][1] == "3" ){	switch1RadioButton->setChecked(FALSE);	switch2RadioButton->setChecked(FALSE);	switch3RadioButton->setChecked(TRUE);	switch4RadioButton->setChecked(FALSE);    }else if ( Swi[L][1] == "4" ){	switch1RadioButton->setChecked(FALSE);	switch2RadioButton->setChecked(FALSE);	switch3RadioButton->setChecked(FALSE);	switch4RadioButton->setChecked(TRUE);    }else if ( Swi[L][1] == "" ){	switch1RadioButton->setChecked(FALSE);	switch2RadioButton->setChecked(FALSE);	switch3RadioButton->setChecked(FALSE);	switch4RadioButton->setChecked(FALSE);    }        if ( Swi[L][2] == "5" ){	switch5RadioButton->setChecked(TRUE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "6" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(TRUE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "7" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(TRUE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "8" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(TRUE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "9" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(TRUE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "10" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(TRUE);	switch11RadioButton->setChecked(FALSE);    }else if ( Swi[L][2] == "11" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(TRUE);    }else if ( Swi[L][2] == "" ){	switch5RadioButton->setChecked(FALSE);	switch6RadioButton->setChecked(FALSE);	switch7RadioButton->setChecked(FALSE);	switch8RadioButton->setChecked(FALSE);	switch9RadioButton->setChecked(FALSE);	switch10RadioButton->setChecked(FALSE);	switch11RadioButton->setChecked(FALSE);    }    str = QString ("%0").arg(L+1, 0, 'f', 0);    LineEdit1->setText( str );}//定值删除;void SwitchForm::Del(){    Swi[L][0] == "";    Swi[L][1] == "";    Swi[L][2] == "";    LineEdit2->setText( "" );    switch1RadioButton->setChecked(FALSE);    switch2RadioButton->setChecked(FALSE);    switch3RadioButton->setChecked(FALSE);    switch4RadioButton->setChecked(FALSE);        switch5RadioButton->setChecked(FALSE);    switch6RadioButton->setChecked(FALSE);    switch7RadioButton->setChecked(FALSE);    switch8RadioButton->setChecked(FALSE);    switch9RadioButton->setChecked(FALSE);    switch10RadioButton->setChecked(FALSE);    switch11RadioButton->setChecked(FALSE);        switch_Table->setText(L, 0, "");    switch_Table->setText(L, 1, "");    switch_Table->setText(L, 2, "");}//定值保存;void SwitchForm::save(){    int i, j;    QDir::setCurrent("/root/FaultRecorder/");    QFile file( "switch_ratedvalue.DAT" );    file.open( IO_WriteOnly );    QTextStream stream( &file );    QString str;    Swi[L][0] = LineEdit2->text();    switch_Table->setText(L, 0, Swi[L][0]);    if ( switch1RadioButton->isChecked() ){	Swi[L][1] = "1";	str = switch1RadioButton->text();    }else if ( switch2RadioButton->isChecked() ){	Swi[L][1] = "2";	str = switch2RadioButton->text();    }else if ( switch3RadioButton->isChecked() ){	Swi[L][1] = "3";	str = switch3RadioButton->text();    }else if ( switch4RadioButton->isChecked() ){	Swi[L][1] = "4";	str = switch4RadioButton->text();    }else {	Swi[L][1] = "";	str = "";    }    switch_Table->setText(L, 1, str);        if ( switch5RadioButton->isChecked() ){	Swi[L][2] = "5";	str = switch5RadioButton->text();    }else if ( switch6RadioButton->isChecked() ){	Swi[L][2] = "6";	str = switch6RadioButton->text();    }else if ( switch7RadioButton->isChecked() ){	Swi[L][2] = "7";	str = switch7RadioButton->text();    }else if ( switch8RadioButton->isChecked() ){	Swi[L][2] = "8";	str = switch8RadioButton->text();    }else if ( switch9RadioButton->isChecked() ){	Swi[L][2] = "9";	str = switch9RadioButton->text();    }else if ( switch10RadioButton->isChecked() ){	Swi[L][2] = "10";	str = switch10RadioButton->text();    }else if ( switch11RadioButton->isChecked() ){	Swi[L][2] = "11";	str = switch11RadioButton->text();    }else {	Swi[L][2] = "";	str = "";    }    switch_Table->setText(L, 2, str);        for ( i = 0; i < 128; i++ ){	for ( j = 0; j < 3; j++){	    stream<<Swi[i][j];	    stream<<" ";	}	stream<<"\n";    }    delPushButton->setEnabled(FALSE);    savePushButton->setEnabled(FALSE);    editPushButton->setEnabled(TRUE);    LineEdit1->setEnabled(FALSE);    LineEdit2->setEnabled(FALSE);    switch1RadioButton->setEnabled(FALSE);    switch2RadioButton->setEnabled(FALSE);    switch3RadioButton->setEnabled(FALSE);    switch4RadioButton->setEnabled(FALSE);    switch5RadioButton->setEnabled(FALSE);    switch6RadioButton->setEnabled(FALSE);    switch7RadioButton->setEnabled(FALSE);    switch8RadioButton->setEnabled(FALSE);    switch9RadioButton->setEnabled(FALSE);    switch10RadioButton->setEnabled(FALSE);    switch11RadioButton->setEnabled(FALSE);    file.close();}

⌨️ 快捷键说明

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