• paip.提升用户体验c++ 拖曳使用总结..


    paip.提升用户体验------c++ qt 拖曳使用总结..


    作者Attilax ,  EMAIL:1466519819@qq.com 
    来源:attilax的专栏
    地址:http://blog.csdn.net/attilax


    1.头文件添加dragEnterEvent,dropEvent 俩个事件
    ------------------


    protected:
        void dragEnterEvent(QDragEnterEvent *event);
        void dropEvent(QDropEvent *event);


    2. 实现CPP
    -------------
    原理:
     setAcceptDrops(true); // [[1]]: 使label可接受拖放操作
      void dragEnterEvent(QDragEnterEvent *event);
        void dropEvent(QDropEvent *event);

    -------------------cpp--------------------
     
     
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
       this->setAcceptDrops(true);
        //setAcceptDrops(true); // [[1]]: 使label可接受拖放操作
    }


    //ati c920
    #include <QDragEnterEvent>
    void MainWindow::dragEnterEvent(QDragEnterEvent *event)
    {
        if (event->mimeData()->hasFormat("text/uri-list"))
            event->acceptProposedAction();
    }
    void MainWindow::dropEvent(QDropEvent *event)
    {
        QList<QUrl> urls = event->mimeData()->urls();
        if (urls.isEmpty())
           return;
        QString fileName = urls.first().toLocalFile();
    //    if (fileName.isEmpty())
    //        return;
       ui->lineEdit->setText(fileName);
      //  QMessageBox::about(NULL, "About", fileName);
       // traveDir(fileName);


    }
    //c920 end




    参考:


    QT拖拽功能简介 - pcsuite的专栏 - 博客频道 - CSDN.NET.htm
  • 相关阅读:
    HDU6393(LCA + RMQ + 树状数组) n边图,两点最短距离 , 修改边权
    POJ 2763 (LCA +RMQ+树状数组 || 树链部分) 查询两点距离+修改边权
    HDU6396 (贪心+fread 挂)
    使用hadoop自带的例子作测试 笔记三
    hadoop的布暑方式 笔记二
    1 Hadoop原理介绍 笔记一
    ssh+flex
    openssh升级过程
    redhat5yum源配置
    struts2实现权限拦截
  • 原文地址:https://www.cnblogs.com/attilax/p/15199536.html
Copyright © 2020-2023  润新知