Results 1 to 15 of 15

Thread: use signal&slot between two tabs

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Join Date
    Jul 2008
    Location
    Munich
    Posts
    73
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: use signal&slot between two tabs

    I hope I did something wrong. Maybe you can help me solve my old problem. I post my code here. My app is to display the camera output images in QGLWidget.

    MyThread: in its run method, it does the while-loop
    Qt Code:
    1. run()
    2. {
    3. while(flag)
    4. {
    5. IplImage *lp_color = t_camera.get_image();
    6. myQLWidget->setCurrentImageIpl(lp_color);
    7. cvReleaseImage(&lp_color);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    MyQLWidget: in charge of updating the texture when it receives any image.
    I am using SIGNAL & SLOT in MyQLWidget, because in method setCurrentImageIpl(), I cannot directly call updateGL(). This is because OpenGl & Thread issue... So in setCurrentImageIpl() I emit a SIGNAL to a SLOT, the SLOT will do updateGL() for me.
    Qt Code:
    1. MyQLWidget::setCurrentImageIpl()
    2. {
    3.  
    4. ...(set image)
    5. imageData = ...;
    6. update = true;
    7. emit newData();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    newData is connect to SLOT updateImage()

    Qt Code:
    1. MyQLWidget::updateImage()
    2. {
    3. this->updateGL();
    4. }
    5.  
    6. MyQLWidget::paintGL()
    7. {
    8. if(update)
    9. glTexSubImage2D = (.....imageData);
    10. }
    To copy to clipboard, switch view to plain text mode 

    During displaying the first few frames that grasped by camera, my program crashes. Not every time. I don't know where is the problem. When it crashes, the reason is that the imageData is not set jet, so when update texture it crashes.

    I set breakpoint, and found that in the first few steps, ...emit... executes twice, but updateImage() only once. Maybe this causes the crash, I am not sure.

    Hard to explain what I did in my code here.
    Last edited by stella1016; 25th July 2008 at 18:55.

Similar Threads

  1. Replies: 2
    Last Post: 23rd July 2012, 08:42
  2. QTabWidget with same tabs
    By Djony in forum Qt Programming
    Replies: 20
    Last Post: 24th December 2011, 12:20
  3. How to make "west" tabs horizontal?
    By plumbum in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2007, 10:32
  4. Switching off all tabs in QTabWidget
    By Gopala Krishna in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2006, 17:10
  5. Removing Tabs
    By NewGuy in forum Qt Programming
    Replies: 6
    Last Post: 22nd July 2006, 22:46

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.