Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qt camera gridlayout
Forum Updated to NodeBB v4.3 + New Features

qt camera gridlayout

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 548 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nils90
    wrote on last edited by
    #1

    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");
    }
    }

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved