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 OpenCV Play Pause and Stop Video
Forum Updated to NodeBB v4.3 + New Features

QT OpenCV Play Pause and Stop Video

Scheduled Pinned Locked Moved Solved General and Desktop
37 Posts 2 Posters 7.7k 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.
  • S Stevendragoes

    maybe @J.Hilk could help me?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #27

    @Stevendragoes Can you show the destructor of your MainWindow?
    Also, when closing your app you should first stop the playback if active.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Stevendragoes
      wrote on last edited by
      #28

      @jsulm this is my destructor

      MainWindow::~MainWindow()
      {
          cap.release();
          delete ui;
      }
      
      
      1 Reply Last reply
      0
      • S Offline
        S Offline
        Stevendragoes
        wrote on last edited by
        #29

        @jsulm I have also attached the close event captured for reference

        void MainWindow::closeEvent(QCloseEvent *event)    //To confirm that the user really wants to quit the application
        {
            QMessageBox::StandardButton exitBtn = QMessageBox::question( this, "MainWindow",tr("Are you sure you want to exit?\n"), QMessageBox::Cancel | QMessageBox::No | QMessageBox::Yes,QMessageBox::Yes);
            if (exitBtn == QMessageBox::Yes) {
                event->accept();
            } else {
                event->ignore();
            }
        }
        
        jsulmJ 1 Reply Last reply
        0
        • S Stevendragoes

          @jsulm I have also attached the close event captured for reference

          void MainWindow::closeEvent(QCloseEvent *event)    //To confirm that the user really wants to quit the application
          {
              QMessageBox::StandardButton exitBtn = QMessageBox::question( this, "MainWindow",tr("Are you sure you want to exit?\n"), QMessageBox::Cancel | QMessageBox::No | QMessageBox::Yes,QMessageBox::Yes);
              if (exitBtn == QMessageBox::Yes) {
                  event->accept();
              } else {
                  event->ignore();
              }
          }
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #30

          @Stevendragoes I would stop the timer in closeEvent if it is running and user wants to quit.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Stevendragoes
            wrote on last edited by
            #31

            Hi @jsulm I have implemented timer->stop() but it still gives me the same error. I am not too sure why.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Stevendragoes
              wrote on last edited by
              #32

              Hi @jsulm
              I think i have solved the problem

              w.setAttribute(Qt::WA_DeleteOnClose, true);
              

              this was inside the main.cpp. I am not sure why this happens.

              jsulmJ 2 Replies Last reply
              0
              • S Stevendragoes

                Hi @jsulm
                I think i have solved the problem

                w.setAttribute(Qt::WA_DeleteOnClose, true);
                

                this was inside the main.cpp. I am not sure why this happens.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #33

                @Stevendragoes said in QT OpenCV Play Pause and Stop Video:

                w.setAttribute

                What is w? Maybe it was double delete?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • S Stevendragoes

                  Hi @jsulm
                  I think i have solved the problem

                  w.setAttribute(Qt::WA_DeleteOnClose, true);
                  

                  this was inside the main.cpp. I am not sure why this happens.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #34

                  @Stevendragoes said in QT OpenCV Play Pause and Stop Video:

                  w.set

                  Now I see the problem: w is allocated on the stack and there is no need to delete it explicitly (what Qt::WA_DeleteOnClose does), so it was double delete.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  3
                  • S Offline
                    S Offline
                    Stevendragoes
                    wrote on last edited by
                    #35

                    @jsulm I suspect is double delete. w is the MainWindow Setup in the main.cpp
                    The Code is as follows

                    #include "mainwindow.h"
                    #include <QApplication>                                         //Widgets Events Handling, Mouse Movements
                    
                    
                    int main(int argc, char *argv[])                                //All Executions are going to begin
                    {
                        QApplication a(argc, argv);                                 //Create the QApplication Object to Handle Events etc.
                        MainWindow w;
                        w.showMaximized();
                        w.show();
                        return a.exec();
                    }
                    
                    
                    

                    on other hand, do u mind if use my solution to mark it as solved?

                    jsulmJ 1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Stevendragoes
                      wrote on last edited by
                      #36

                      @jsulm
                      Thank you so much for your assistance in these few days. Now I need to move on to interfacing with an inbuilt camera or USB connected camera to do my object tracking.

                      1 Reply Last reply
                      1
                      • S Stevendragoes

                        @jsulm I suspect is double delete. w is the MainWindow Setup in the main.cpp
                        The Code is as follows

                        #include "mainwindow.h"
                        #include <QApplication>                                         //Widgets Events Handling, Mouse Movements
                        
                        
                        int main(int argc, char *argv[])                                //All Executions are going to begin
                        {
                            QApplication a(argc, argv);                                 //Create the QApplication Object to Handle Events etc.
                            MainWindow w;
                            w.showMaximized();
                            w.show();
                            return a.exec();
                        }
                        
                        
                        

                        on other hand, do u mind if use my solution to mark it as solved?

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #37

                        @Stevendragoes There is no need for Qt::WA_DeleteOnClose, see my previous comment.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        2

                        • Login

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