Results 1 to 4 of 4

Thread: Constructing QWidget in QWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2008
    Location
    Seoul, Korea
    Posts
    5
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Windows

    Question Constructing QWidget in QWidget

    I'm trying to play MPlayer in QWidget.

    Qt Code:
    1. #include "moviemainwindow.h"
    2.  
    3. #include <qvariant.h>
    4. #include <qlayout.h>
    5. #include <qtooltip.h>
    6. #include <qwhatsthis.h>
    7. #include <qaction.h>
    8. #include <qmenubar.h>
    9. #include <qpopupmenu.h>
    10. #include <qtoolbar.h>
    11. #include <qpoint.h>
    12.  
    13. /*
    14.  * Constructs a MovieMainWindow as a child of 'parent', with the
    15.  * name 'name' and widget flags set to 'f'.
    16.  *
    17.  */
    18. MovieMainWindow::MovieMainWindow( QWidget* parent, const char* name, WFlags fl )
    19. : QWidget( parent, name, fl )
    20. {
    21. // (void)statusBar();
    22. if ( !name )
    23. setName( "MovieMainWindow" );
    24.  
    25. //Part for Constucting inner QWidget(screen).
    26. this->screen = new ScreenMainWindow(this, "", WStyle_Customize|WStyle_NormalBorder);
    27. this->screen->move( QPoint(0, 0) );
    28. this->screen->show();
    29.  
    30. //Constructing PushButtons
    31. this->playBtn = new QPushButton("play", this);
    32. this->playBtn->setGeometry( 60, 180, 40, 30 );
    33.  
    34. this->pauseBtn = new QPushButton("pause", this);
    35. this->pauseBtn->setGeometry( 100, 180, 40, 30 );
    36.  
    37. this->stopBtn = new QPushButton("stop", this);
    38. this->stopBtn->setGeometry( 140, 180, 40, 30);
    39.  
    40. //SIGNAL and SLOT
    41. QObject::connect(playBtn, SIGNAL(clicked()), this, SLOT(play()));
    42. QObject::connect(pauseBtn, SIGNAL(clicked()), this, SLOT(pause()));
    43. QObject::connect(stopBtn, SIGNAL(clicked()), this, SLOT(stop()));
    44.  
    45. languageChange();
    46. resize( QSize(240, 210).expandedTo(minimumSizeHint()) );
    47. clearWState( WState_Polished );
    48.  
    49. }
    50.  
    51. /*
    52.  * Destroys the object and frees any allocated resources
    53.  */
    54. MovieMainWindow::~MovieMainWindow()
    55. {
    56. // no need to delete child widgets, Qt does it all for us
    57. }
    58.  
    59. /*
    60.  * Sets the strings of the subwidgets using the current
    61.  * language.
    62.  */
    63. void MovieMainWindow::languageChange()
    64. {
    65. setCaption( tr( "Movie" ) );
    66. }
    67.  
    68. //Part for play
    69. void MovieMainWindow::play()
    70. {
    71. this->proc1 = new QProcess(this);
    72. this->proc1->addArgument( "mplayer" );
    73. this->proc1->addArgument( "-slave" );
    74. this->proc1->addArgument( "-identify" );
    75. this->proc1->addArgument( "-quiet" );
    76. this->proc1->addArgument( "-wid" );
    77. this->proc1->addArgument( this->WID.setNum((int)(this->screen->winId())) );
    78. this->proc1->addArgument( "/MPlayer/MPlayer-1.0pre8/[P]test.avi" );
    79. this->proc1->start();
    80. }
    81.  
    82. //Part for pause
    83. void MovieMainWindow::pause()
    84. {
    85. this->proc1->writeToStdin( "pause\n" );
    86. }
    87.  
    88. //Part for stop/quit
    89. void MovieMainWindow::stop()
    90. {
    91. this->proc1->writeToStdin( "quit\n" );
    92. }
    To copy to clipboard, switch view to plain text mode 

    I succeeded to control MPlayer by using QProcess.
    My problem is when I clicked "play" button,
    I intended to play MPlayer in inner QWidget(screen).
    but when I did, MPlayer was played center of monitor.
    To do that I intended, what should I do?? Help me plz......
    Last edited by jpn; 5th August 2008 at 12:17. Reason: missing [code] tags

Similar Threads

  1. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  2. Error in put one QWidget in another QWidget
    By xjtu in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2008, 16:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.