Results 1 to 2 of 2

Thread: Display camera in a GridLayout

  1. #1
    Join Date
    Nov 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Display camera in a GridLayout

    Hey !

    I am trying to display what my webcam views in a gridLayout. Here is my code : it compiles but doesn't work : it display a window with the different buttons but not the video from my camera. Can anyone help me to make it work ? I have already seen the Qt documentation and Qt examples but it didn't help me. I am a very beginner in Qt. I work on Windows and Qt5.

    Qt Code:
    1. #include "fenetre.h"
    2.  
    3. Fenetre::Fenetre(): QWidget()
    4. {
    5.  
    6. m_up= new QPushButton("up", this);
    7. m_right= new QPushButton("right", this);
    8. m_down= new QPushButton("down", this);
    9. m_left= new QPushButton("left", this);
    10. m_mode= new QPushButton("deplacement", this);
    11.  
    12. //QLabel *image = new QLabel(this);
    13. //image->setPixmap(QPixmap("smile.png"));
    14.  
    15. camera = new QCamera;
    16. cvf = new QCameraViewfinder;
    17. camera->start();
    18.  
    19.  
    20. layout = new QGridLayout;
    21. layout-> addWidget(m_up,0,1);
    22. layout-> addWidget(m_right,1,2);
    23. layout-> addWidget(m_down,2,1);
    24. layout-> addWidget(m_left,1,0);
    25. layout-> addWidget(m_mode,0,0);
    26. //layout->addWidget(image,1,1);
    27. layout-> addWidget(cvf,1,1);
    28. setLayout(layout);
    29.  
    30. QObject::connect(m_mode, SIGNAL(clicked()), this, SLOT(changerMode()));
    31. }
    32.  
    33. void Fenetre::changerMode()
    34. {
    35. if (m_mode->text()=="deplacement")
    36. {
    37. m_up->setText("accelerer");
    38. m_down->setText("ralentir");
    39. m_mode->setText("vision");
    40. }
    41. else
    42. {
    43. m_up->setText("up");
    44. m_down->setText("down");
    45. m_mode->setText("deplacement");
    46. }
    47. }
    To copy to clipboard, switch view to plain text mode 

    Thank you very much for your help !

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Display camera in a GridLayout

    And where do you call QCameraViewfinder::setMediaObject() with the pointer to your QCamera instance? Did you expect the viewfinder to look around in your code for a camera and magically hook up to it?

Similar Threads

  1. Replies: 0
    Last Post: 1st July 2013, 09:59
  2. display camera capture on label->setpixmap
    By mdaud in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2013, 21:50
  3. gridlayout unwanted display
    By PstdEr in forum Newbie
    Replies: 1
    Last Post: 1st April 2013, 01:39
  4. Display the camera frame in real time
    By alex_lue in forum Qt Programming
    Replies: 8
    Last Post: 27th July 2007, 11:31
  5. does gridlayout really lay out?
    By illuzioner in forum Newbie
    Replies: 2
    Last Post: 26th February 2006, 01:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.