Results 1 to 5 of 5

Thread: QVtkWidget under QTabWidget interactions are not working

  1. #1
    Join Date
    May 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default QVtkWidget under QTabWidget interactions are not working

    Dear Qt Users,

    I am facing a problem with QVtkWidget under QTabWidget. I have vtkImageViewer2 to bind with QVtkWidget and vtkInteractorStyleImage for the render window interactions.
    QVtkWidget does not catch any event from keyboard or from mouse when I put QVtkWidget inside QTabWidget. But, If I use QVtkWidget outside QTabWidget then it's work fine.

    I tried this code in MainWindow Constructor

    QApplication::sendPostedEvents();
    QApplication:rocessEvents(QEventLoop::AllEvents);

    Also I tried, InstallEventFilter, still it is not working. Could you please guide me, what I need to do for proper interaction working ?


    Best
    Muhammad Jawad

  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: QVtkWidget under QTabWidget interactions are not working

    I tried this code in MainWindow Constructor
    Putting any sort of code like this in a main window constructor is useless, since there is no event loop running at the time the main window is being built. The event loop does not start running until after QApplication::exec() has been called from main().

    Also I tried, InstallEventFilter, still it is not working.
    Where? How? And what "is not working"? The event filter?

  3. #3
    Join Date
    May 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QVtkWidget under QTabWidget interactions are not working

    Here is my code:

    Qt Code:
    1. vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
    2. vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
    3. // this class is reimplemented from VtkInteractorStyleImage
    4. vtkSmartPointer<MyVtkInteractorStyleImage> myInteractorStyle = vtkSmartPointer<MyVtkInteractorStyleImage>::New();
    5.  
    6. renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
    7. myInteractorStyle->SetImageViewer(imageViewer);
    8.  
    9. imageViewer->SetupInteractor(renderWindowInteractor);
    10.  
    11. QVTKWidget *qvtkWidget = this->ptrMainWindow->GetQVtkWidget(viewerId);
    12. qvtkWidget->SetRenderWindow(imageViewer->GetRenderWindow());
    13. imageViewer->GetRenderer()->ResetCamera();
    14. imageViewer->Render();
    15. qvtkWidget->GetRenderWindow()->SetInteractor(imageViewer->GetRenderWindow()->GetInteractor());
    To copy to clipboard, switch view to plain text mode 

    When I use QVtkWidget as a mainwindow child then the interactions are working perfectly. But, I need to put three QVtkWidgets. So, I used QTabWidget inside mainwindow and put three QVtkWidgets in multiple tabs of QTabWidget. It load the data, but the interactions become jam.

    Any help.
    Last edited by anda_skoa; 13th May 2016 at 09:38. Reason: missing [code] tags

  4. #4
    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: QVtkWidget under QTabWidget interactions are not working

    Sorry, but I don't know enough about vtk to help. Doesn't Kitware have a forum for vtk? You might be better off to post your question there.

  5. #5
    Join Date
    May 2016
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QVtkWidget under QTabWidget interactions are not working

    But I think, this is not the problem at vtk side. It may be more on Qt side. But any way thanks for your time.

Similar Threads

  1. keyPressEvent() not working for a tab within QTabWidget
    By sadastronaut in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2014, 19:13
  2. QTabWidget QSS transparency not working under Windows
    By il_gatto in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2011, 12:02
  3. Replies: 1
    Last Post: 6th December 2010, 15:18
  4. QT Class GUI Interactions??
    By mikey33 in forum Newbie
    Replies: 3
    Last Post: 19th November 2009, 02:01
  5. Block for interactions
    By mpi in forum Qt Programming
    Replies: 1
    Last Post: 30th October 2009, 09:32

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.