详解QT基于Mplayer媒体播放器应用教程

移动开发
QT基于Mplayer媒体播放器应用教程是本文要介绍的内容,本文通过代码来实现QT基于mplayer播放器的案例,具体代码的实现来看内容。

QT基于Mplayer媒体播放器应用教程是本文要介绍的内容,主要是来了解并学习QT总媒体播放器的应用,本文通过代码来实现QT基于mplayer播放器的案例,具体代码的实现来看内容。

播放器全屏音量时间进度都已经实现,追加快捷键设计...

  1. MAINWINDOW.H  
  2. #ifndefMAINWINDOW_H  
  3. #defineMAINWINDOW_H  
  4. #include  
  5. #include  
  6. #include  
  7. #include  
  8. #include  
  9. #include  
  10. namespaceUi{  
  11. classMainWindow;  
  12. }  
  13. classMainWindow:publicQMainWindow  
  14. {  
  15. Q_OBJECT  
  16. public:  
  17. explicitMainWindow(QWidget*parent=0);  
  18. ~MainWindow();  
  19. private:  
  20. Ui::MainWindow*ui;  
  21. QProcess*mplayerProcess;  
  22. QStringfilename;  
  23. QTimer*poller;  
  24. QWidget*w;  
  25. QDockWidget*shapesDockWidget1;  
  26. QDockWidget*shapesDockWidget2;  
  27. QTimer*interval;  
  28. QAction*at2;  
  29. QAction*at3;  
  30. QAction*at4;  
  31. QAction*at5;  
  32. QMenu*menu;  
  33. QPointm_dragPosition;  
  34. privateslots:  
  35. voidon_textEdit_3_textChanged();  
  36. voidon_spinBox_editingFinished();  
  37. voidon_spinBox_valueChanged(int);  
  38. voidwriteSettings();  
  39. voidreadSettings();  
  40. voidon_pushButton_10_clicked();  
  41. voidon_pushButton_9_clicked();  
  42. voidon_pushButton_6_clicked();  
  43. voidon_pushButton_5_clicked();  
  44. voidon_pushButton_3_clicked();  
  45. voidon_pushButton_2_clicked();  
  46. voidon_horizontalSlider_2_valueChanged(intvalue);  
  47. voidon_pushButton_8_clicked();  
  48. voidon_pushButton_clicked();  
  49. voidon_pushButton_7_clicked();  
  50. voidon_pushButton_4_clicked();  
  51. voidtimeLineChanged(intpos);  
  52. voidpollCurrentTime();  
  53. voidreject();  
  54. voidenterFullScreen();  
  55. voidenter();  
  56. voidcloseEvent(QCloseEvent*ex);  
  57. voidcontextMenuEvent(QContextMenuEvent*event);  
  58. voidmouseMoveEvent(QMouseEvent*event);  
  59. voidmousePressEvent(QMouseEvent*event);  
  60. booleventFilter(QObject*obj,QEvent*ev);  
  61. };  
  62.  
  63. #endif//MAINWINDOW_H  
  64. MAINWINDOW.cpp  
  65. #include"mainwindow.h"  
  66. #include"ui_mainwindow.h"  
  67. #include"QProcess"  
  68. #include  
  69. #include  
  70. #include  
  71. #include  
  72. #include  
  73. #include  
  74. #include  
  75. #include  
  76. #include  
  77. #include  
  78. #include  
  79. #include  
  80. #include  
  81. #include  
  82.  
  83. MainWindow::MainWindow(QWidget*parent):  
  84.  
  85. QMainWindow(parent),  
  86. ui(newUi::MainWindow)  
  87. {  
  88. ui->setupUi(this);  
  89.  
  90. mplayerProcess=newQProcess(this);  
  91. shapesDockWidget1=newQDockWidget(QString::fromLocal8Bit("播放界面"));  
  92. shapesDockWidget1->setWidget(ui->widget_4);  
  93. shapesDockWidget2=newQDockWidget(QString::fromLocal8Bit("播放时间"));  
  94. shapesDockWidget2->setWidget(ui->widget_2);  
  95.  
  96. //QWidget*wi=newQWidget(this);  
  97. //wi->resize(400,300);  
  98. addDockWidget(Qt::BottomDockWidgetArea,shapesDockWidget1);  
  99. addDockWidget(Qt::BottomDockWidgetArea,shapesDockWidget2);  
  100.  
  101. shapesDockWidget2->show();  
  102. QVBoxLayout*vLayout=newQVBoxLayout(this);  
  103. vLayout->addWidget(ui->widget);  
  104. w=newQWidget(this);  
  105. w->setLayout(vLayout);  
  106. this->setCentralWidget(w);  
  107. poller=newQTimer(this);  
  108. interval=newQTimer(this);  
  109. connect(interval,SIGNAL(timeout()),this,SLOT(reject()));  
  110. interval->start(1000);  
  111. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),this,SLOT(timeLineChanged(int)));  
  112. connect(mplayerProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(reject()));  
  113. connect(poller,SIGNAL(timeout()),this,SLOT(pollCurrentTime()));  
  114. //setWindowOpacity(0.95);  
  115. QPaletteplt=palette();  
  116. //plt.setColor(QPalette::Background,QColor("Black"));  
  117. plt.setColor(QPalette::Background,QColor("Grey"));  
  118. this->setPalette(plt);  
  119. ui->label_4->setText(QString::fromLocal8Bit("不是全屏"));  
  120. w->setAutoFillBackground(true);  
  121. QAction*at1=newQAction("进入全屏",this);  
  122. this->addAction(at1);  
  123. this->setAcceptDrops(true);  
  124. at1->setShortcuts(QList()< 
  125. //connect(at1,SIGNAL(triggered()),this,SLOT(enterFullScreen()));  
  126. at2=newQAction(QString::fromLocal8Bit("暂停/开始"),this);  
  127. this->addAction(at2);  
  128. this->setAcceptDrops(true);  
  129. at2->setShortcuts(QList()< 
  130. connect(at2,SIGNAL(triggered()),this,SLOT(enter()));  
  131. at3=newQAction(QString::fromLocal8Bit("全屏"),this);  
  132. this->addAction(at3);  
  133. this->setAcceptDrops(true);  
  134. at3->setShortcuts(QList()< 
  135. connect(at3,SIGNAL(triggered()),ui->pushButton_5,SLOT(click()));  
  136. at4=newQAction(QString::fromLocal8Bit("退出全屏"),this);  
  137. this->addAction(at4);  
  138. this->setAcceptDrops(true);  
  139. at4->setShortcuts(QList()< 
  140. connect(at4,SIGNAL(triggered()),ui->pushButton_6,SLOT(click()));  
  141. at5=newQAction(QString::fromLocal8Bit("打开"),this);  
  142. this->addAction(at5);  
  143. this->setAcceptDrops(true);  
  144. at5->setShortcuts(QList()< 
  145. connect(at5,SIGNAL(triggered()),ui->pushButton_4,SLOT(click()));  
  146. QAction*at6=newQAction("前进",this);  
  147. this->addAction(at6);  
  148. this->setAcceptDrops(true);  
  149. at6->setShortcuts(QList()< 
  150. connect(at6,SIGNAL(triggered()),ui->pushButton_9,SLOT(click()));  
  151. QAction*at7=newQAction("后退",this);  
  152. this->addAction(at7);  
  153. this->setAcceptDrops(true);  
  154. at7->setShortcuts(QList()< 
  155. connect(at7,SIGNAL(triggered()),ui->pushButton_10,SLOT(click()));  
  156. QAction*at8=newQAction("提高音量",this);  
  157. this->addAction(at8);  
  158. this->setAcceptDrops(true);  
  159. at8->setShortcuts(QList()< 
  160. connect(at8,SIGNAL(triggered()),ui->pushButton_2,SLOT(click()));  
  161. QAction*at9=newQAction("降低",this);  
  162. this->addAction(at9);  
  163. this->setAcceptDrops(true);  
  164. at9->setShortcuts(QList()< 
  165. connect(at9,SIGNAL(triggered()),ui->pushButton_3,SLOT(click()));  
  166. this->readSettings();  
  167. w->installEventFilter(this);  
  168. intx=(QApplication::desktop()->width()-this->width())/2;  
  169. inty=(QApplication::desktop()->height()-this->height())/2;  
  170. this->move(x,y);  
  171. this->resize(800,600);  
  172. //QDesktopWidget*desktop=QApplication::desktop();  
  173. //intwidth=desktop->width();  
  174. //intheight=desktop->height();  
  175. }  
  176. voidMainWindow::enterFullScreen()  
  177. {  
  178. mplayerProcess->write("vo_fullscreen/n");  
  179.  
  180. }  
  181. voidMainWindow::enter()  
  182. {  
  183. if(ui->label_6->text()==QString::fromLocal8Bit("开始"))  
  184. {  
  185. mplayerProcess->write("pause/n");  
  186.  
  187. poller->stop();  
  188. ui->label_6->setText(QString::fromLocal8Bit("暂停"));  
  189. }  
  190. elseif(ui->label_6->text()==QString::fromLocal8Bit("暂停"))  
  191. {  
  192. mplayerProcess->write("pause/n");  
  193. mplayerProcess->write("get_time_length/n");  
  194. poller->start(10);  
  195. ui->label_6->setText(QString::fromLocal8Bit("开始"));  
  196. }  
  197. }  
  198.  
  199. MainWindow::~MainWindow()  
  200. {  
  201. deleteui;  
  202. }  
  203.  
  204. voidMainWindow::pollCurrentTime()  
  205.  
  206. {  
  207. mplayerProcess->write("get_time_pos/n");  
  208. //qDebug()text();  
  209. //log->append(QString(buffer));  
  210. ui->textEdit->setText(QString::number(ui->horizontalSlider->maximum()/3600)
  211. +":"+QString::number((ui->horizontalSlider->maximum()/60)%60)+":"
  212. +QString::number(ui->horizontalSlider->maximum()%60));  
  213. ui->textEdit_2->setText(QString::number(ui->horizontalSlider->value()/3600)
  214. +":"+QString::number((ui->horizontalSlider->value()/60)%60)+":"+QString::number(ui->horizontalSlider->value()%60));  
  215. }  
  216.  
  217. voidMainWindow::reject()  
  218. {  
  219.  
  220. this->setFocus();  
  221. //ui->label_5->setText(QString::number(ui->horizontalSlider->maximum()/3600)+":"
  222. +QString::number((ui->horizontalSlider->maximum()/60)%60)+":"
  223. +QString::number(ui->horizontalSlider->maximum()%60));  
  224. //ui->label_5->setText(QString::number(ui->horizontalSlider->value()/3600)+":"
  225. +QString::number((ui->horizontalSlider->value()/60)%60)+":"
  226. +QString::number(ui->horizontalSlider->value()%60));  
  227.  
  228. while(mplayerProcess->canReadLine())  
  229.  
  230. {  
  231. QByteArraybuffer(mplayerProcess->readLine());  
  232. ui->textEdit_3->append(QString(buffer));  
  233. //qDebug()< 
  234. //log->append(QString(buffer));  
  235. //Onvérifiesionaeudesréponses  
  236. //réponseàget_video_resolution:ANS_VIDEO_RESOLUTION='x' 
  237. if(buffer.startsWith("ANS_VIDEO_RESOLUTION"))  
  238. {  
  239. buffer.remove(0,21);//vireANS_VIDEO_RESOLUTION=  
  240.  
  241. buffer.replace(QByteArray("'"),QByteArray(""));  
  242. buffer.replace(QByteArray(""),QByteArray(""));  
  243. buffer.replace(QByteArray("/n"),QByteArray(""));  
  244. buffer.replace(QByteArray("/r"),QByteArray(""));  
  245. intsepIndex=buffer.indexOf('x');  
  246. intresX=buffer.left(sepIndex).toInt();  
  247. intresY=buffer.mid(sepIndex+1).toInt();  
  248. ui->widget->setMinimumSize(resX,resY);  
  249. }  
  250.  
  251. //réponseàget_time_length:ANS_LENGTH=xx.yy  
  252. elseif(buffer.startsWith("ANS_LENGTH"))  
  253. {  
  254. buffer.remove(0,11);//vireANS_LENGTH=  
  255.  
  256. buffer.replace(QByteArray("'"),QByteArray(""));  
  257. buffer.replace(QByteArray(""),QByteArray(""));  
  258. buffer.replace(QByteArray("/n"),QByteArray(""));  
  259. buffer.replace(QByteArray("/r"),QByteArray(""));  
  260. floatmaxTime=buffer.toFloat();  
  261. ui->horizontalSlider->setMaximum(static_cast(maxTime+1));  
  262. }  
  263. //réponseàget_time_pos:ANS_TIME_POSITION=xx.y  
  264. elseif(buffer.startsWith("ANS_TIME_POSITION"))  
  265. {  
  266. buffer.remove(0,18);//vireANS_TIME_POSITION=  
  267. buffer.replace(QByteArray("'"),QByteArray(""));  
  268. buffer.replace(QByteArray(""),QByteArray(""));  
  269. buffer.replace(QByteArray("/n"),QByteArray(""));  
  270. buffer.replace(QByteArray("/r"),QByteArray(""));  
  271. floatcurrTime=buffer.toFloat();  
  272. ui->horizontalSlider->setValue(static_cast(currTime+1));  
  273. }  
  274. }  
  275. }  
  276. voidMainWindow::timeLineChanged(intpos)  
  277. {  
  278. mplayerProcess->write(QString("seek"+QString::number(pos)+"2/n").toUtf8());  
  279. }  
  280. voidMainWindow::on_pushButton_4_clicked()  
  281. {  
  282. filename=QFileDialog::getOpenFileName(this,QString::fromLocal8Bit("文件类型"),".",QString::fromLocal8Bit("文问类型(*.*)"));  
  283. if(filename!=NULL)  
  284. {  
  285. poller->stop();  
  286. mplayerProcess->close();  
  287. this->setWindowTitle(filename);  
  288. ui->pushButton_7->setEnabled(true);  
  289. mplayerProcess=newQProcess(this);  
  290. QStringexefile=QCoreApplication::applicationDirPath()+"/mplayer/mplayer.exe";  
  291. qDebug()< 
  292. //qDebug()< 
  293. QStringListargs;  
  294. args<<"-slave";  
  295. //Etonveutnepasavoirtropdechoseparser:)  
  296. args<<"-zoom";  
  297. //args<<"-quiet";  
  298. //args<<"-xy1024";  
  299. //args<<"-wid"<(w->winId()))<<"-x"<<"1680"<<"-y"<<"1050";  
  300. args<<"-wid"<(w->winId()));  
  301. args<<"-vo"<<"direct3d";  
  302. //args<<"-vo"<<"gl";  
  303. //vo=gl 
  304. //direct3d  
  305. //mplayer-fs-zoom-vofbdev-xy1024filename  
  306. args< 
  307. mplayerProcess->setProcessChannelMode(QProcess::MergedChannels);  
  308. mplayerProcess->start(exefile,args);  
  309. if(!mplayerProcess->waitForStarted(3000))  
  310. {  
  311. qDebug("allez,cherchelebug:o");  
  312. }  
  313. //Onrécupèrelesinfosdebase  
  314. mplayerProcess->write("get_video_resolution/n");  
  315. mplayerProcess->write("get_time_length/n");  
  316. mplayerProcess->write("get_time_length/n");  
  317. //mplayerProcess->write("get_time_pos/n");  
  318. poller->start(10);  
  319. //mplayerProcess->write("pause/n");  
  320. ui->label_6->text()=="开始";  
  321. }  
  322. }  
  323. voidMainWindow::on_pushButton_7_clicked()  
  324. {  
  325. if(ui->label_6->text()==QString::fromLocal8Bit("开始"))  
  326. {  
  327. mplayerProcess->write("pause/n");  
  328. poller->stop();  
  329. ui->label_6->setText(QString::fromLocal8Bit("暂停"));  
  330. }  
  331. elseif(ui->label_6->text()==QString::fromLocal8Bit("暂停"))  
  332. {  
  333. mplayerProcess->write("pause/n");  
  334. mplayerProcess->write("get_time_length/n");  
  335. poller->start(10);  
  336. ui->label_6->setText(QString::fromLocal8Bit("开始"));  
  337. }  
  338. }  
  339. voidMainWindow::on_pushButton_clicked()  
  340. {  
  341.  
  342. mplayerProcess->write("vo_fullscreen/n");  
  343. }  
  344. voidMainWindow::on_pushButton_8_clicked()  
  345. {  
  346. QMessageBox::information(this,QString::fromLocal8Bit("AboutMdieaPlayer"),  
  347.  
  348. QString::fromLocal8Bit("快捷键说明:/n打开:A/n暂停/开始:space/n全屏:D/n取消全屏:S/n快进:
  349. right/n后退:left/n音量提高:top/n音量降低:down/nID:Jammy基于mplayer开发版本0.06"));  
  350. }  
  351. voidMainWindow::on_horizontalSlider_2_valueChanged(intvalue)  
  352. {  
  353. inti;  
  354. QStringstr;QByteArraystr1;  
  355. mplayerProcess->write("volume"+str1+"/n");  
  356. i=-(40-value);str=QString::number(i);  
  357. strstr1=str.toAscii();  
  358. mplayerProcess->write("volume"+str1+"/n");  
  359. //qDebug()< 
  360. }  
  361. voidMainWindow::on_pushButton_2_clicked()  
  362. {  
  363. mplayerProcess->write("volume+1/n");  
  364. }  
  365. voidMainWindow::on_pushButton_3_clicked()  
  366. {  
  367. mplayerProcess->write("volume-1/n");  
  368. }  
  369. voidMainWindow::on_pushButton_5_clicked()  
  370. {  
  371. this->setWindowFlags(Qt::Window);  
  372. w->setWindowFlags(Qt::FramelessWindowHint);  
  373. this->showFullScreen();  
  374. shapesDockWidget1->hide();  
  375. shapesDockWidget2->hide();  
  376. ui->label_4->setText(QString::fromLocal8Bit("全屏"));  
  377. }  
  378. voidMainWindow::on_pushButton_6_clicked()  
  379. {  
  380. this->setWindowFlags(Qt::Window);  
  381. this->resize(800,600);  
  382. //w->setWindowFlags(Qt::FramelessWindowHint);  
  383. this->showNormal();  
  384. shapesDockWidget1->show();  
  385. shapesDockWidget2->show();  
  386. intx=(QApplication::desktop()->width()-this->width())/2;  
  387. inty=(QApplication::desktop()->height()-this->height())/2;  
  388. this->move(x,y);  
  389. ui->label_4->setText(QString::fromLocal8Bit("不是全屏"));  
  390. }  
  391. voidMainWindow::on_pushButton_9_clicked()  
  392. {  
  393. QStringstr;  
  394. str=QString::number(ui->spinBox->value());  
  395. mplayerProcess->write("seek+"+str.toAscii()+"/n");  
  396. qDebug()< 
  397. qDebug()<<"seek+"+str.toAscii()+"/n";  
  398. }  
  399. voidMainWindow::on_pushButton_10_clicked()  
  400. {  
  401. QStringstr;  
  402. str=QString::number(ui->spinBox->value());  
  403. mplayerProcess->write("seek-"+str.toAscii()+"/n");  
  404. }  
  405. voidMainWindow::on_spinBox_valueChanged(int)  
  406. {  
  407. w->setFocus();  
  408. }  
  409. voidMainWindow::on_spinBox_editingFinished()  
  410. {  
  411. w->setFocus();  
  412. }  
  413. voidMainWindow::closeEvent(QCloseEvent*ex)  
  414. {  
  415. //inta=QMessageBox::information(NULL,
  416. QString::fromLocal8Bit("对话框"),
  417. QString::fromLocal8Bit("是否需要退出"),
  418. QString::fromLocal8Bit("确定"),
  419. QString::fromLocal8Bit("取消"),NULL,0,-1);  
  420. //if(a==0)  
  421. //{  
  422. writeSettings();  
  423. //ex->accept();  
  424. //}  
  425. //elseif(a==1)  
  426. //{  
  427. //ex->ignore();  
  428. //}  
  429. }  
  430. voidMainWindow::writeSettings()  
  431. {  
  432. QSettingssettings("Software","IconEditor");  
  433. settings.beginGroup("mainWindow");  
  434. settings.setValue("size",size());  
  435. settings.setValue("state",saveState());  
  436. settings.endGroup();  
  437. }  
  438. voidMainWindow::readSettings()  
  439. {  
  440. QSettingssettings("Software","IconEditor");  
  441. settings.beginGroup("mainWindow");  
  442. resize(settings.value("size").toSize());  
  443. restoreState(settings.value("state").toByteArray());  
  444. settings.endGroup();  
  445. }  
  446. voidMainWindow::contextMenuEvent(QContextMenuEvent*event)  
  447. {  
  448. shapesDockWidget1->show();  
  449. shapesDockWidget2->show();  
  450. //QCursorcur=this->cursor();  
  451. menu=newQMenu(this);  
  452. menu->addAction(at5);  
  453. menu->addAction(at2);  
  454. menu->addAction(at3);  
  455. menu->addAction(at4);  
  456. //menu->exec(cur.pos());  
  457. menu->exec(event->globalPos());//  
  458. //this->setContextMenuPolicy(Qt::ActionsContextMenu);  
  459. }  
  460. voidMainWindow::mouseMoveEvent(QMouseEvent*event)  
  461. {  
  462. //if(ui->label_4->text()==QString::fromLocal8Bit("不是全屏"))  
  463. //{  
  464. //if(event->buttons()&Qt::LeftButton){  
  465. //move(event->globalPos()-m_dragPosition);  
  466. ////move(event->globalPos()-m_dragPosition);  
  467. //event->accept();  
  468. //}  
  469. //}  
  470. }  
  471. voidMainWindow::mousePressEvent(QMouseEvent*event)  
  472. {  
  473. //if(ui->label_4->text()==QString::fromLocal8Bit("不是全屏"))  
  474. //{  
  475. //if(event->button()==Qt::LeftButton){  
  476. //m_dragPosition=event->globalPos()-frameGeometry().topLeft();  
  477. //ui->widget->move(m_dragPosition);  
  478. //event->accept();  
  479. //}  
  480. //}  
  481. }  
  482. boolMainWindow::eventFilter(QObject*obj,QEvent*event)  
  483. {  
  484. if(obj==w){  
  485. if(event->type()==QEvent::MouseButtonDblClick){  
  486. QMouseEvent*ev=static_cast(event);  
  487. if(ev->buttons()&Qt::LeftButton)  
  488. {  
  489. if(ui->label_4->text()==QString::fromLocal8Bit("不是全屏"))  
  490. {  
  491. this->setWindowFlags(Qt::Window);  
  492. w->setWindowFlags(Qt::FramelessWindowHint);  
  493. this->showFullScreen();  
  494. shapesDockWidget1->hide();  
  495. shapesDockWidget2->hide();  
  496. ui->label_4->setText(QString::fromLocal8Bit("全屏"));  
  497. }  
  498. elseif(ui->label_4->text()==QString::fromLocal8Bit("全屏"))  
  499. {  
  500. this->setWindowFlags(Qt::Window);  
  501. this->resize(800,600);  
  502. //w->setWindowFlags(Qt::FramelessWindowHint);  
  503. this->showNormal();  
  504. shapesDockWidget1->show();  
  505. shapesDockWidget2->show();  
  506. intx=(QApplication::desktop()->width()-this->width())/2;  
  507. inty=(QApplication::desktop()->height()-this->height())/2;  
  508. this->move(x,y);  
  509. ui->label_4->setText(QString::fromLocal8Bit("不是全屏"));  
  510. }  
  511. //m_dragPosition=ev->globalPos()-frameGeometry().topLeft();  
  512. //ev->accept();  
  513. }  
  514. returntrue;  
  515. }  
  516. elseif(event->type()==QEvent::MouseButtonPress){  
  517. QMouseEvent*ev=static_cast(event);  
  518. if(ev->buttons()&Qt::LeftButton)  
  519. {  
  520. if(ui->label_4->text()==QString::fromLocal8Bit("全屏"))  
  521. {  
  522. shapesDockWidget1->hide();  
  523. shapesDockWidget2->hide();  
  524. }  
  525. elseif(ui->label_4->text()==QString::fromLocal8Bit("不是全屏"))  
  526. {  
  527. m_dragPosition=ev->globalPos()-frameGeometry().topLeft();  
  528. ev->accept();  
  529. w->setFocus();  
  530. }  
  531. //m_dragPosition=ev->globalPos()-frameGeometry().topLeft();  
  532. //ev->accept();  
  533. }  
  534. returntrue;  
  535. }elseif(event->type()==QEvent::MouseMove){  
  536. QMouseEvent*ev=static_cast(event);  
  537. if(ev->buttons()&Qt::LeftButton){  
  538. if(ui->label_4->text()==QString::fromLocal8Bit("不是全屏"))  
  539. {  
  540. //move(event->globalPos()-m_dragPosition);  
  541. move(ev->globalPos()-m_dragPosition);  
  542. ev->accept();  
  543. w->setFocus();  
  544. }  
  545. }  
  546. }  
  547. else{  
  548. returnfalse;  
  549. }  
  550. }  
  551. else{  
  552.  
  553. //passtheeventontotheparentclass  
  554. returnQMainWindow::eventFilter(obj,event);  
  555. }  
  556. returntrue;  
  557. }  
  558. voidMainWindow::on_textEdit_3_textChanged()  
  559. {  
  560. w->setFocus();  
  561. }  
  562.  
  563. **************************************************  
  564. main.cpp  
  565. #include  
  566. #include"mainwindow.h"  
  567. intmain(intargc,char*argv[])  
  568. {  
  569. QApplicationa(argc,argv);  
  570. MainWindoww;  
  571. w.show();  
  572. returna.exec();  

小结:详解QT基于Mplayer媒体播放器应用教程的内容介绍完了,希望通过学习QT播放器的案例的实现,能对你有所帮助。更多关于QT的相关内容,请单击QT开发频道

责任编辑:zhaolei 来源: CDDN博客
相关推荐

2011-09-06 10:46:19

QT播放器

2015-10-19 17:28:00

MPlayer媒体播放器开源

2011-06-24 10:21:11

Qt phonon 多媒体

2011-09-06 11:25:08

2011-06-10 13:42:50

QT mplayer 播放器

2010-01-25 09:43:02

Chrome OS媒体播放器

2023-08-26 19:07:40

VLC旋转视频

2021-02-24 14:04:23

Linux媒体播放器桌面

2011-07-26 09:16:16

Windows媒体播放器

2011-06-10 14:06:32

QT mplayer

2010-03-04 09:34:35

Ubuntu Oper

2011-07-04 15:13:31

QT MPlayer 移植

2022-12-13 07:27:22

Windows微软

2011-06-13 09:33:04

2011-06-27 11:23:21

Qt 音乐播放器

2021-09-30 05:34:21

Windows 11操作系统微软

2009-02-17 23:41:43

Mplayer播放器常见问题

2022-01-05 20:09:29

Windows 11操作系统微软

2015-05-21 15:25:42

VLC播放器

2011-06-24 16:50:06

QT 框架 OpenCV
点赞
收藏

51CTO技术栈公众号