Results 1 to 4 of 4

Thread: QVTKWidget doesnt work with QFileSystemModel (VTK 7, Qt 5.5)

  1. #1
    Join Date
    Jun 2016
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Question QVTKWidget doesnt work with QFileSystemModel (VTK 7, Qt 5.5)

    I am trying to use a VTK renderer in Qt central widget with a file explorer tree view in a QDockWidget using Qt creator 4.0. It seams that qvtkwidget doesnt work with QFileSystemModel in a QTreeView for some reason. Here is the code fragment that generate the error:'

    Qt Code:
    1. qvtkWidget = new QVTKWidget(centralWidget)
    2.  
    3. ....
    4. QTreeView *treeView = new QTreeView(dockWidgetContents);
    5. QFileSystemModel *dirModel = new QFileSystemModel(treeView);
    6. QString sPath=dirModel->myComputer().toString();
    7. dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs |QDir::AllEntries);
    8. dirModel->setRootPath(sPath);
    9. treeView->setModel(dirModel);
    To copy to clipboard, switch view to plain text mode 

    The above code produces a run-time error

    handled exception at 0x6016A4F0 (Qt5Gui.dll) in myApp.exe: 0xC0000005: Access violation reading location 0x000000E8.

    Unhandled exception at 0x6036A4F0 (Qt5Gui.dll) in myApp.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
    The error stops when i either remove QVTKWidget or comment out the code line

    Qt Code:
    1. dirModel->setRootPath(sPath);
    To copy to clipboard, switch view to plain text mode 

    I have built VTK 7.0.0 in release mode, so I cant debug into the code. I am using installed Qt 5.5.1 built for mvsc2013 32bit on windows 10

    Anyone with any idea?
    Last edited by Kind.m; 2nd June 2016 at 20:01.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QVTKWidget doesnt work with QFileSystemModel (VTK 7, Qt 5.5)

    You will have to make a debug build in order to resolve this. It likely has nothing to do with the VTK widget, and more likely to do with 1) an uninitialized or null pointer, 2) the local declarations of "treeView" and "dirModel" pointers hiding class member variables of the same name (which are therefore unitialized), or 3) something you are doing in the "...." that corrupts memory or the stack. How do you know that dirModel->myComputer() isn't returning an empty string?

    In Windows a 0xC0000005 error using means you tried to access something through an null or invalid pointer.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

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

    Default Re: QVTKWidget doesnt work with QFileSystemModel (VTK 7, Qt 5.5)

    Thank you d_stranz!

    I reproduced the error on a Qt designer; I dragged and added QVTKWidget, a Dock Widget and then I dragged and added a TreeView to the Dock Widget. up to now it runs fine.

    Then I added only the code lines 4,5 & 9 to 13 bellow:

    Qt Code:
    1. ainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
    2. {
    3.  
    4. vtkRenderingOpenGL2ObjectFactory *of = vtkRenderingOpenGL2ObjectFactory::New();
    5. vtkObjectFactory::RegisterFactory(of);
    6.  
    7. ui->setupUi(this);
    8.  
    9. QFileSystemModel *dirModel = new QFileSystemModel(ui->treeView);
    10. QString sPath="c:/";
    11. dirModel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs |QDir::AllEntries);
    12. dirModel->setRootPath(sPath);
    13. ui->treeView->setModel(dirModel);
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 


    I just realized that the creator output also reports:

    QWidget::repaint: Recursive repaint detected
    The program has unexpectedly finished.
    Could it be because I am using a 32bit libraries to access the file system on a 64bit system?
    I am trying to building VTK with Qt support for debug mode as well as 64 bit, i did not succeed yet.
    Last edited by Kind.m; 3rd June 2016 at 06:39.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: QVTKWidget doesnt work with QFileSystemModel (VTK 7, Qt 5.5)

    Could it be because I am using a 32bit libraries to access the file system on a 64bit system?
    No. Your program will not link if you try to link a 64-bit program to 32-bit libraries, so therefore I assume you are building a 32-bit program. There is no problem running a 32-bit program on 64-bit Windows; you can't do the reverse.

    I don't see anything wrong with the constructor; the eror must be elsewhere in your code (or in the way you are adding the VTK widget to your code.

    There should be VTK examples for using VTK with Qt. Why don't you start with one of them and add your tree view and other Qt widgets to that instead of trying to add VTK to a Qt project?

    The recursive paint message should be a big hint to you that your code is causing a repaint on some widget from within your paintEvent handler. If you are trying to resize a widget or do something else to it that would cause it to need to be repainted while in the paintEvent, then this will result in the error. The paintEvent is for painting, nothing else. Anything else you need to do to modify a widget's appearance has to be done elsewhere (like a resize, mouse, keyboard, hide, show, etc. event).
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Shortcut doesnt work
    By tuli in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2012, 15:01
  2. Qwt Tex Text Doesnt work for me
    By gbmtoday in forum Qwt
    Replies: 1
    Last Post: 21st November 2010, 19:48
  3. connect doesnt work
    By john_god in forum Newbie
    Replies: 4
    Last Post: 23rd November 2008, 09:36
  4. ldapsearch doesnt work.
    By shamik in forum General Discussion
    Replies: 0
    Last Post: 3rd April 2008, 07:25
  5. How come this doesnt work?
    By ShaChris23 in forum Newbie
    Replies: 8
    Last Post: 16th June 2007, 04:43

Tags for this Thread

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.