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 8317373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:34:44+00:00 2026-06-08T21:34:44+00:00

I need some help now. I would love if someone could help we with

  • 0

I need some help now. I would love if someone could help we with “transferring” my QT based code to work with my C# application.

Lets say I have this simple QT Class:

class ItShouldWork : public QObject
{
    Q_OBJECT

public:
    ItShouldWork(QObject* parent = 0) : QObject(parent){}
    QString id() const { return objectName(); }

};

Now I want to be able to access this class with Visual Studio C#, I’ve tried creating an unmanaged dll and access through an wrapper, tried to create an COM component but right now I’m completely stuck so I’m going back to the beginning with this simple class. I’ve seen that you can use an extern “C” with __declspec(dllexport) like this:

extern "C" __declspec(dllexport) double Subtract(double a, double b)

and then use _dllImport in .net, this works fine with the function above but when adding for example a QString to it it doesn’t recognize my dll anymore and a dllNotFoundException is thrown.

Then I thought maybe you need a wrapper of some kind, yeah and how do you do that then..? googled away but nothing to really help me with c++ and qt functions.

A small step by step on how creating a dll and a c-wrapper or creating a COM component dll directly would be awesome, I don’t really care how it’s done but if you know a way, please help me with a small tutorial? I’m going crazy…

  • 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-06-08T21:34:45+00:00Added an answer on June 8, 2026 at 9:34 pm

    C++/CLI is the way to go, I think.
    See: Wrapping unmanaged C++ with C++/CLI – a proper approach

    And especially: http://www.delmarlearning.com/companions/content/1592009638/bonus/009638_BonusCh02.pdf

    Going into that subject in depth is not easy to do in a forum post. But with some research you should be able to create something useable quite quickly.
    C++/CLI takes some getting used to, if you’re coming from C/C++. It’s a bit more restrictive, especially regarding mixing managed and unmanaged types. But the literature will guide you there.

    EDIT:
    In response to OP’s comment to my answer(also see Comment by Ramhound, Me), here is an example I got here:
    Have a look at the content behind the link to see the context of m_impl…

    String ^ CSimpleObjectWrapper::ToString(void) 
    { 
        wchar_t szStr[100]; 
        HRESULT hr = m_impl->ToString(szStr, ARRAYSIZE(szStr)); 
        if (FAILED(hr)) 
        { 
            Marshal::ThrowExceptionForHR(hr); 
        } 
        // Marshal PWSTR to System::String and return it. 
        return gcnew String(szStr); 
    } 
    

    EDIT 2:
    Also depending on the desired depth/complexity/power of your wrapper, you might think about wrapping your classes in C++/CLI “ref class”es instead of using DllImport.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got some code off the Internet and now I just need help to
I would love some help on a particular design. This is the code I
I need some help. Here's what I'm getting right now: img ref I need
Greetings good people - I need some help. I have until now buildt web-pages
i'm new at IPhone SDK Developing and now i need some help. I have
I am working on an iPad application and need some help from you guys.
I need some help with my BBCode replacing. Right now i'm doing the following
Ok here's a little problem I would love to get some help on. I
now I need some help with Serializing my arraylist. Now I have managed to
I need some help with escaping the quotes in this script, I have code

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.