zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    FPGA学习之基本结构
    凸优化和机器学习
    第6篇如何访问pod
    吉日嘎拉DotNet.BusinessV4.2中的一处bug,及我的修复和扩展
    吉日嘎拉C#快速开发平台V4.0到V4.2升级记
    布隆过滤器简介及实现-----源自数学之美
    poj [1753]
    Zookeeper Hello World
    获取用户真实IP,php实现
    mysql中engine=innodb和engine=myisam的区别
  • 原文地址:https://www.cnblogs.com/attilax/p/15199536.html
Copyright © 2011-2022 走看看