ied.txt

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow *w = new MainWindow;
    a.setStyleSheet("MainWindow{background-color: rgb(102, 102, 102);}");
    w->show();
    
    return a.exec();
}




#include "mainwindow.h"
#include <QtGui>
#include <QFileDialog>
#include "ScdChooseDlg.h"
#include "ScdTreeView.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setWindowIcon(QIcon(":/IED_Tool/image/app.png"));
    //setWindowIcon(QIcon("image/app.png"));
    centerWidget = new QWidget;
    tipLabel = new QLabel(CHS("此工具可通过IED名称导出关联虚端子\n请选择SCD文件:"));
    scdFileLabel = new QLabel(CHS("scd文件:"));
    scdDirEdit = new QLineEdit;
    butt_scdSelect = new QPushButton(CHS("选择"));

    scdOK = new QPushButton(CHS("确 定"));
    mainQuit = new QPushButton(CHS("退 出"));

    scdFileLabel->setBuddy(scdDirEdit);

    connect(butt_scdSelect, SIGNAL(clicked()),
            this, SLOT(scdSelect()));
    connect(scdOK, SIGNAL(clicked()),
            this, SLOT(importScdFile()));
    connect(mainQuit, SIGNAL(clicked()), this, SLOT(close()));

    mainLayout =  new QVBoxLayout;
    scdLayout = new QHBoxLayout;
    buttLayout = new QHBoxLayout;

    scdLayout->addWidget(scdFileLabel);
    scdLayout->addWidget(scdDirEdit);
    scdLayout->addWidget(butt_scdSelect);

    buttLayout->addStretch();
    buttLayout->addWidget(scdOK);
    buttLayout->addSpacing(100);
    buttLayout->addWidget(mainQuit);
    buttLayout->addStretch();

    mainLayout->addWidget(tipLabel);
    mainLayout->addSpacing(20);
    mainLayout->addLayout(scdLayout);
    mainLayout->addSpacing(35);
    mainLayout->addLayout(buttLayout);
    mainLayout->addStretch();
    
    centerWidget->setLayout(mainLayout);

//    set UI style
    butt_scdSelect->setStyleSheet("color: white; \
                                   width: 60px; \
                                   height: 20px; \
                                   border-radius: 10px; \
                                   background-color: rgb(70, 168, 25);");

    thisStyleSheet(this);
    this->resize(560, 300);
    this->setCentralWidget(centerWidget);
}

MainWindow::~MainWindow()
{
    
}

void MainWindow::scdSelect()
{
    QString dir = QFileDialog::getOpenFileName(this,
                     CHS("请选择scd文件:"), "C:",
                     tr("ICD file(*.scd *.icd *.cid *.xml)"));

    if(!dir.isEmpty())
    {
        scdDirEdit->setText(dir);
    }
}

void MainWindow::importScdFile()
{
    QString qsFileName = scdDirEdit->text();
    IEDBriefInforList lst;
    qsFileName = ScdChooseDlg::getChooseIEDList(qsFileName, lst);
    if ( qsFileName.isEmpty() )
        return;
    
    QProgressDialog progressDlg( this );
    progressDlg.setCancelButtonText(QObject::tr("&Cancel"));
    progressDlg.setRange(0, lst.size());
    progressDlg.setWindowTitle(QObject::tr("Prase SCD File"));
    progressDlg.setWindowModality(Qt::WindowModal);
    progressDlg.setMinimumDuration(0);
    
    ServerPtrList lstSrv;
    IEDBriefInforList::iterator it = lst.begin();
    for( int i = 0; it != lst.end(); ++it, ++i )
    {
        if (progressDlg.wasCanceled())
            break;
        
        progressDlg.setValue(i);
        progressDlg.setLabelText(QObject::tr("Prase server number %1 of %2...")
                .arg(i).arg(lst.size()));
        qApp->processEvents();

        execute( (*it).ied_name );

    }
}

void MainWindow::execute(QString ied_name)
{
    exportVirtualTerminal(ied_name);
}





#include "mainwindow.h"

void MainWindow::thisStyleSheet(QWidget *w)
{
    w->setStyleSheet("QLabel{ \
                        color: lightgray; \
                        font-size: 12pt;} \
                      QLineEdit{ \
                        padding-right: 15px; \
                        height: 18px; \
                        border: 2px; \
                        border-radius: 9px; \
                        font: 12pt;} \
                      QPushButton{ \
                        color: white; \
                           width: 80px; \
                        height: 25px; \
                        border-radius: 12px; \
                        font-size: 12pt; \
                        background-color: rgb(70, 168, 25);}");
}
1. 使用宏定义定义一个函数 宏定义通常用于定义常量或者函数式的宏,但也可以用于模拟简单的函数定义。例如,我们可以定义一个宏来计算两个数的和: ```c #define SUM(a, b) ((a) + (b)) ``` 这里使用括号是为了确保宏展开时的操作数不会受到运算符优先级的影响。 2. 外部变量声明,新建一个`Ied.c`,声明一个变量,在`main`函数里边调用 首先,在`Ied.c`文件中声明一个外部变量: ```c // Ied.c int externalVar = 10; // 声明并初始化一个外部变量 ``` 然后在另一个文件中,比如`main.c`,你可以声明这个外部变量,并在`main`函数中使用它: ```c // main.c extern int externalVar; // 声明外部变量,表明其定义在其他文件中 int main() { // 调用外部变量 printf("%d\n", externalVar); return 0; } ``` 记得要确保`Ied.c`和`main.c`在同一个编译单元中被编译,或者在链接时能够正确找到`Ied.c`中定义的变量。 3. 使用条件编译完成两个函数定义 条件编译通常用于根据预定义的宏或者编译器指令来包含或排除代码块。以下是一个使用条件编译定义两个不同函数的示例: ```c // 如果定义了MY_CONDITION则定义functionA,否则定义functionB #ifdef MY_CONDITION #define FUNCTION A #else #define FUNCTION B #endif // 使用条件编译后的宏定义函数 void FUNCTION() { // 函数实现 } ``` 在这个例子中,根据`MY_CONDITION`是否被定义,将决定编译器包含`functionA`的定义还是`functionB`的定义。 4. 结构体定义,定义一个结构体`student`,成员包括学号、姓名、身高、性别。 下面是如何定义一个名为`student`的结构体的示例: ```c // 定义一个student结构体 struct student { int id; // 学号 char name[50]; // 姓名 float height; // 身高 char gender; // 性别,'M'表示男性,'F'表示女性 }; ``` 这里,`id`是整型,`name`是一个字符数组(字符串),`height`是浮点型,`gender`是字符型,用来存储性别标识。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值