zoukankan      html  css  js  c++  java
  • 18.QT-QPlainEdit 信号与槽

    #include "Widget.h"
    
    Widget::Widget(QWidget *parent) :
        QWidget(parent),
        edit(this)
    {
        edit.setGeometry(0,0,280,300);
    
        Undo=new QPushButton("重做",this);
        Redo=new QPushButton("撤销",this);
        Cut=new QPushButton("剪切",this);
        Copy=new QPushButton("复制",this);
        Paste=new QPushButton("拷贝",this);
        all=new QPushButton("全选",this);
        clear=new QPushButton("删除",this);
        Undo->setGeometry(290,0,100,30);
        Redo->setGeometry(290,40,100,30);
        Cut->setGeometry(290,80,100,30);
        Copy->setGeometry(290,120,100,30);
        Paste->setGeometry(290,160,100,30);
        all->setGeometry(290,200,100,30);
        clear->setGeometry(290,240,100,30);
        Undo->setEnabled(false);
        Redo->setEnabled(false);
        Cut->setEnabled(false);
        Copy->setEnabled(false);
    
        
        connect(Undo, SIGNAL(clicked()) , &edit ,SLOT(undo()));
        connect(Redo, SIGNAL(clicked()) ,  &edit ,SLOT(redo()));
        connect(Cut, SIGNAL(clicked()) ,    &edit ,SLOT(cut()));
        connect(Copy, SIGNAL(clicked()) ,    &edit ,SLOT(copy()));
        connect(Paste, SIGNAL(clicked()) ,    &edit ,SLOT(paste()));
        connect(all, SIGNAL(clicked()) ,  &edit ,SLOT(selectAll()));
        connect(clear, SIGNAL(clicked()) ,  &edit ,SLOT(clear()));
    
        
        connect(&edit, SIGNAL(copyAvailable(bool)) , this ,SLOT(oncopyAvailable(bool)));
        connect(&edit, SIGNAL(redoAvailable(bool)) , this ,SLOT(onredoAvailable(bool)));
        connect(&edit, SIGNAL(undoAvailable(bool)) , this ,SLOT(onundoAvailable(bool)));
        connect(&edit, SIGNAL(selectionChanged()) , this ,SLOT(onselectionChanged()));
    
    }
    
    void    Widget::oncopyAvailable ( bool yes )
    {
           Cut->setEnabled(yes);
           Copy->setEnabled(yes);
    }
    
    void    Widget::onredoAvailable( bool available )
    {
           Redo->setEnabled(available);
    }
    
    void    Widget::onundoAvailable ( bool available )
    {
           Undo->setEnabled(available);
    }

    文章来源:https://www.cnblogs.com/lifexy/p/9003918.html

  • 相关阅读:
    【664】日常记录
    【663】dataframe 删掉指定行或者列
    【662】TensorFlow GPU 相关配置
    【661】Python split 指定多个分隔符
    【660】TensorFlow 或者 keras 版本问题
    FFMPEG视音频编解码
    cpplint中filter参数
    升级pip之后出现sys.stderr.write(f“ERROR: {exc}“)
    特征点三角化恢复3D点
    VIO——陀螺仪零偏估计
  • 原文地址:https://www.cnblogs.com/xiongjim/p/9673928.html
Copyright © 2011-2022 走看看