Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    edit 
= new QTextEdit;
    
this->setCentralWidget(edit);
    setAcceptDrops(
true);
    
this->setWindowTitle(tr("Text Editor"));
}

MainWindow::
~MainWindow()
{
}

void MainWindow::dragEnterEvent(QDragEnterEvent* event)
{
    
if(event->mimeData()->hasFormat("text/uri-list"))
        
event->acceptProposedAction();
}

void MainWindow::dropEvent(QDropEvent* event)
{
    QList
<QUrl> uri = event->mimeData()->urls();
    
if(uri.isEmpty())
        
return;
    QString file 
= uri.first().toLocalFile();
    
if(file.isEmpty())
        
return;
    
this->setWindowTitle(tr("%1 -- %2").arg(file).arg("Drag File"));
}
posted on 2011-08-02 22:39 ccsdu2009 阅读(516) 评论(0)  编辑 收藏 引用 所属分类: QT编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理