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

  • 相关阅读:
    路由器01---k2刷Pandora
    nginx+flask02---概念
    Nginx06---实现websocket
    Nginx05---负载均衡 upsteam
    nginx+uwsgi02---django部署(推荐)
    Nginx04---实现直播
    Nginx04---编译安装
    mybatis+mysql insert添加数据后返回数据主键id---(转)
    JSON字符串转换为Map
    Http post请求案例
  • 原文地址:https://www.cnblogs.com/xiongjim/p/9673928.html
Copyright © 2011-2022 走看看