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
  • 相关阅读:
    ASP.NET MVC3 中设置htmlAttribute
    oracle查看表空间的几个sql
    SQL Server 中 sysobjects表
    Openal简介
    [转]DBUSGLIB Binding,GLIB事件与DBUS事件是如何关联的
    ffmpeg简介
    ffmpeg安装FAAC
    ffserver error
    Openal教程(二)
    centos下安装qt时出现/usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.9' not found
  • 原文地址:https://www.cnblogs.com/attilax/p/15199536.html
Copyright © 2011-2022 走看看