qt camera gridlayout



  • Hello !

    I am trying to display what my webcam sees in a GridLayout. I cannot make it work. Here is my code : it compiles but nothing happens. Can anyone help me ?
    #include "fenetre.h"

    Fenetre::Fenetre(): QWidget()
    {

    m_up= new QPushButton("up", this);
    m_right= new QPushButton("right", this);
    m_down= new QPushButton("down", this);
    m_left= new QPushButton("left", this);
    m_mode= new QPushButton("deplacement", this);

    //QLabel *image = new QLabel(this);
    //image->setPixmap(QPixmap("smile.png"));

    camera = new QCamera;
    cvf = new QCameraViewfinder;
    camera->start();

    layout = new QGridLayout;
    layout-> addWidget(m_up,0,1);
    layout-> addWidget(m_right,1,2);
    layout-> addWidget(m_down,2,1);
    layout-> addWidget(m_left,1,0);
    layout-> addWidget(m_mode,0,0);
    //layout->addWidget(image,1,1);
    layout-> addWidget(cvf,1,1);
    setLayout(layout);

    QObject::connect(m_mode, SIGNAL(clicked()), this, SLOT(changerMode()));
    }

    void Fenetre::changerMode()
    {
    if (m_mode->text()=="deplacement")
    {
    m_up->setText("accelerer");
    m_down->setText("ralentir");
    m_mode->setText("vision");
    }
    else
    {
    m_up->setText("up");
    m_down->setText("down");
    m_mode->setText("deplacement");
    }
    }


  • Qt Champions 2016

    @nils90 said:

    Hi
    Have you tried with the
    http://doc.qt.io/qt-5/qtmultimediawidgets-camera-example.html
    to make sure the camera is detected and can show image?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.