zoukankan      html  css  js  c++  java
  • qt杂录

    列表查找

    struct先重载==号

    struct Department
        {
            int Id;
            QString Name;
            QString Telephone;
            QString Contacts;
            bool Department::operator==(const Department &rhs) const
            {
                return (Id == rhs.Id);
            }
        };
    

      

    用qFind查找:

    Department userForFind;
        userForFind.Id=name.toInt();
        QVector<Department>::iterator it = qFind(DepartmentList.begin(), DepartmentList.end(), userForFind); // 查找
    
        if (it != DepartmentList.end()) // 找到了
        {
           ed->dp=*it;
        }
    

    弹窗

    QPushButton *okbtn = new QPushButton(QString::fromLocal8Bit("确定"));
        QPushButton *cancelbtn = new QPushButton(QString::fromLocal8Bit("取消"));
        QMessageBox *mymsgbox = new QMessageBox;
    
        mymsgbox->setIcon(QMessageBox::Warning);
        mymsgbox->setWindowTitle(QString::fromLocal8Bit("删除提示"));
        mymsgbox->setText(QString::fromLocal8Bit("是否确定删除该记录?"));
        mymsgbox->addButton(okbtn, QMessageBox::AcceptRole);
        mymsgbox->addButton(cancelbtn, QMessageBox::RejectRole);
        mymsgbox->show();
        mymsgbox->exec();//阻塞等待用户输入
        if (mymsgbox->clickedButton()==okbtn)//点击了OK按钮
        {
           //dosomething
        } 

    界面事件

    界面载入事件

    void showEvent(QShowEvent *event);
    

      界面退出不一定触发closeEvent事件,但一定会触发hideEvent事件

    void hideEvent(QHideEvent *event);
    

      

  • 相关阅读:
    出差兰州
    出差乌鲁木齐(3)
    依赖倒置原则
    .NET 打印界面
    出差乌鲁木齐2
    出差乌鲁木齐(2)
    出差乌鲁木齐3
    IStyleGallery.AddItem、UpdateItem、RemoveItem用法
    Shapefile记录检索
    c#利用最小二乘法拟合任意次函数曲线(转)
  • 原文地址:https://www.cnblogs.com/ssvip/p/15018790.html
Copyright © 2011-2022 走看看