Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6643003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:59:49+00:00 2026-05-25T23:59:49+00:00

I´m trying to include classfiles dynamically right now and chose to do so by

  • 0

I´m trying to include classfiles dynamically right now and chose to do so by loading the .dll into a QLibrary. The problem I´m having now is, that when I try to call the resolve()-method it returns 0.

EDIT:
In the meantime the problem has been solved and I decided to edit the code, so others can see how it works:

This is the .dll´s header file:

#ifndef DIVFIXTURE_H
#define DIVFIXTURE_H

#include<QObject>
#include<QVariant>

class __declspec(dllexport) DivFixture : public QObject
{
    Q_OBJECT
public:
    Q_INVOKABLE DivFixture();
    Q_INVOKABLE void setNumerator(QVariant num);
    Q_INVOKABLE void setDenominator(QVariant denom);
    Q_INVOKABLE QVariant quotient();

private:
    double numerator, denominator;
};

#endif

this is the dll´s .cpp-file:

#include "testfixture.h"

DivFixture::DivFixture(){}

void DivFixture::setNumerator(QVariant num)
{
    numerator=num.toDouble();
}


void DivFixture::setDenominator(QVariant denom)
{
    denominator=denom.toDouble();
}


QVariant DivFixture::quotient()
{
    QVariant ret;
    ret=numerator/denominator;
    return ret;
}

//non-class function to return pointer to class
extern "C" __declspec(dllexport) DivFixture* create()
{
   return new DivFixture();
}

And this is how I load my class:

currentFixture.setFileName("C:\\somepath\\testFixture.dll");
if(currentFixture.load());
{
    typedef QObject* (*getCurrentFixture)();
    getCurrentFixture fixture=(getCurrentFixture)currentFixture.resolve("create");
    if (fixture)
    {
        Fixture=fixture();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:59:50+00:00Added an answer on May 25, 2026 at 11:59 pm

    You need to export your class using __declspec(dllexport)

    class __declspec(dllexport) DivFixture : public QObject
    {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to include an EPS figure in a document that will be compiled
I am trying to include a .js file into a php file. My folder
I am trying to include the library StringEscapeUtils and everything that I can find
I am trying to include a Facebook like button iFrame that has PHP in
Trying to include a instance variable in a message that a UIAlertView Shows. lostAlert
I am trying include c++ library (DLL) in my c# project but every time
I'm trying to include a premade messageboard, Phorum, into one of my Zend projects.
I'm trying to include in my Windows Form App a way that when user
I'm trying to include a Facebook share iframe on a site that's served using
I'm trying to include an extension methods static class in a dynamically generated assembly,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.