Important: Please read the Qt Code of Conduct -

Problem calling Qt DLL made with into project

  • hi everybody,
    i'm really new to qt so i excuse for my eventually stupid questions.
    my target is to make a shared library dll in qt that i can use in a project.
    I followed all the possible tutorials and forums about how to create something like this and for test i create a stupid 'multiple' library.
    Then i tried to evolve my dll to make what i need (a dll that creates a graphic file using some functions like word spacing and shadows that i can't do with gdi+) the idea is to pass this image from qt dll to my project.

    below the first lines of my sub in the dll where it crashes

    int QTRender::Draw()

    QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();
    bool external_color;
    int text_flags;
    QPixmap pixmap (800,480);
    //making bg image
    QGraphicsScene *scene = new QGraphicsScene();    ------ THIS IS THE LINE THAT CAUSES THE ERROR
    QGraphicsView view(&scene);


    when that line it's called by my .net project i receive the following error:
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt

    Thought it was caused by a bad Qt declaration made by me but this error happens only with QGraphicScene object.
    Hope someone could help me. i will appreciate every help
    thank you

  • I don't know if above code you posted was compiled in dll project, because from what I see line 10 is wrong. "scene" variable is already a pointer, so don't need to pass address of pointer in QGraphicsView constructor.

  • thank you cincirin,
    the line 10 is not executed yet because the error happens on line 9.
    i'm gonna think that i can't use views in shared library
    i really need help

  • [quote author="daniel__" date="1353055182"]i'm gonna think that i can't use views in shared library
    i really need help
    First, you need to create QAplication. Next don't call QApplication::exec in dll because will block host application events. Instead call QApplication::processEvents periodically (e.g. in some timer function)

Log in to reply