Use Qt codes in C++ - c++

I have some codes in Qt Creator that work properly. I need to use this codes but in win32 application in .net framework. Does anyone have any idea how can I do this? I am totally new to Qt and do not know how to use this useful codes in c++ project?
I appreciate any help in advance
I think I could not get my message across. Qt is c++ but It has some differences with the native c++ app that we use in .net framework. so I can't just copy all the codes in my project to run it properly. Can we make a dll or library to use this qt code in .net or not? and how can I do this?
I really need help. Thank you so much

For almost all cases, you do not want to mix .net and Qt in same application. It's less work to just take the logic and rewrite it for .net (managed C++ or C#).
Next best option might be to keep the parts separate and have them communicate through some IPC mechanism.
This is, because any non-trivial Qt code depends on it's own event loop, so getting the existing Qt code play nice with other event loop is always a hassle, and trying to get it play nicely when actual application is managed .net code... No, just no, unless you have a very compelling reason, are expert on both Qt and .net, and have extra time to make it work right.

I'm not sure if you don't know how to download and install Qt or how to create a Qt project in Visual Studio IDE. Try this installation guide.

Do you want to link the Qt library to your win32 c++ app? I think you should build the qt source code first with your win32 compiler. I think you could include the qt header and link the library as normal win32 library to your application after that.

Related

Alternative to VCL on C++Builder

So I'm working at a company and they've been using VCL for GUI development since forever. I'm rather newbie at creating GUI for Windows, but I dislike the options and limitations of the VCL. So I started looking around for other alternatives, are there something better out there?
I've read a lot about WCF but it's Visual Studio only. I also found about QT, but I'm not sure how would I pair C++Builder and the QT Designer software. Is there a package available?
Or if there is a better solution for Windows GUI development with C++Builder - we're using CodeGear's C++Builder 2007 - could you recommend it?
Thanks!
You can use Qt with Builder in conjunction with qmake or cmake(both tools are for project files generation). Well, you can use it with Builder without those generators but then you will have to write all MOC rules yourself and it is a tiresome job.
So my suggestion is to use Qt instead of VCL, especially relatively new Qt feature - Qt Quick which allows you to write UI in declarative fashion
wxWidgets (http://www.wxwidgets.org/) works with C++ Builder, but i am interested to know why you are stuck with C++ Builder? time to move on buddy, I would suggest to move toward QT and use its own QT Creator, Or go for .Net if you prefer.

Alternate of win32 framework for windowing system on windows

I want to develop a custom window system in c++ that should not depend on win32 library. As an example, Google Chrome has an interface that is not similar to windows own interface. Similarly MPCstar and adobe products have their own interfaces. Please help me where to start for such a project?
You can use cross platform
Qt
or
wxWidgets
but in my opinion Qt is better.
Qt is awesome even if you don't need cross platform support. I assure you after using it you won't understand how anyone could ever develop native GUI on frameworks like Win32 and MFC. Its only shortcoming is the size of the DLLs you'll have to distribute with your app.
BTW is C++ a prerequisite? if not, and you only need windows, use .Net.
I believe Qt should do the trick. I've never used it myself but it is platform independent. I know a few applications that use it, and it seems fine.
Qt and WxWidgets are the better options. And since its GUI I think Qt performs better and has greater support and lots of libraries.
Find Qt here!

Programming in C++ with Xcode 4

I want to use Xcode as my major complier for C++. However, I'm having a hard time starting programming. Which kind of project and target should I select if I want to write some applications with user interface?
I've been coding with Xcode for one semester but all the projects were half-done the time I saw them, so I really don't know how to start by myself. I tried the Command Line target but it did not seem to generate an application.
Sorry for asking these naive questions. Thanks for any help!
You can start with a barebones project by going to New -> New Project -> Application (under Mac OS X) -> Command Line Tool. This will give you a basic main() function that you can enter code into. This is what I use alot of the time for algorithm practice.
If you want your app to use a GUI framework, you can either choose the template that #sblom suggested and make a Cocoa Application (here is a good guide to get you started), or you could use a C++ framework such as wxWidgets or Qt (usually used with it's own IDE, Qt Creator).
Note that while Cocoa is in Objective C, you could just as well program in C++ for the core functionality of your app, just make sure the implementation files have a .mm suffix.
You'll need to use Mac OS X -> Application -> Cocoa Application. Unfortunately, it won't exactly be in plain ol' C++, although you can use C++. You'll have to use Objective-C to make actual calls into the Cocoa Framework (well, there are ways to make the calls using straight C/C++, but that's really cumbersome.)
I will highly recommend to use QT but not WX.
We use WX for years in our Valentina Studio application. And we going switch to QT asap. Reasons are that WX on MAC has weak progress. Troubles with Cocoa support. QT looks much more better choice ...

C++ open window hello world

How can you write a C++ program to open a window like this one...
Is it possible or can apps only be ran from the command line?
I'm using the G++ compiler... Do I need something else like visual studio?
Can I do it just by writing code?
Take a look at Qt which is a cross-platform framework that easily builds GUIs.
Then check out a Qt tutorial, do a google search. Here is one that will get you to "hello world"
Also, you might want to check out Code::Blocks as an IDE. It will use your already installed g++ compiler.
You can use Borland C++, Visual C++ they has GUI or wxWindow or GTK library.
GUI programming requires the use of additional libraries. There is a C++ GUI library supplied by Microsoft for Windows called MFC. There are many other GUI libraries out there.
If you use these GUI libraries, you don't need to run the application from the command line.
Search for WinApi Tutorials like this one
there are alot
or you can also you the Visual Studio MFC application wizard and create a dialog application
Microsoft provides a tuturial for doing that:
http://msdn.microsoft.com/en-us/library/bb384843.aspx
The best and most low-level way of doing this would be by using the Windows API:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/learn-to-program-for-windows
Microsoft itself provides excellent tutorials and documentation on how to program with their Windows Application Programming Interface, but there are also numerous other tutorials out there that can be found quickly with a google search.
To create a window like the one you ask about in the question, you would be looking for the following link:
https://learn.microsoft.com/en-us/windows/win32/learnwin32/your-first-windows-program
It might seem daunting at first, but the Windows API is extensive and provides a huge amount of functionality, on top of just creating GUIs. It would probably be worthwhile familiarising yourself with it if you are interested in Windows programming.
You need to use the Windows api from within C++.

Transition from MFC to QT

Currently all our GUI components are written in MFC. Our build environment is:
VC 6
Windows XP
I have no idea whether:
1) We can replace all MFC components with Qt, without changing build environment ?
2) Qt will work with VC6 as any other library?
You answers will help me in getting started, In the mean time I have installed Qt 4 and am trying to build some samples.
If we can replace all MFC components with QT, without changing build environment ?
Yes, you even get a MFC/Qt migration framework cf qt.nokia.com/products/appdev/add-on-products/catalog/4/Windows/qtwinmigrate/
Will Qt work with VC6 as any other library ?
VC6 is more than 10 years old!
Qt supports VC6 until version 4.5
The next release (4.6) will drop VC6 support cf qt.nokia.com/doc/4.6-snapshot/qt4-6-intro.html#performance-optimizations
You probably shouldn’t use VC6 with Qt 4.5. (see doc)
Apart from that: If your project compiles with Qt, you can easily* switch to Qt components. Qt uses its own componentens anyway, so there’s no other dependencies involved.
However, to set up the Qt environment, you might need to do a few changes to your build system, unless you’re not working with QObjects. (Think of the moc pre-processor.)
*: easily in the sense of being able to start using Qt components. The amount of work needed to actually migrate MFC components to those of Qt is something I don’t know anything about.
Replacing MFC to QT requires a big work to do. First of all you should think whether you need that. Second, Qt could be integrated with Visual Studio.
I learned something very useful when trying to port one client's MFC application to Qt.
I do a lot of refactoring. That doesn't scare me at all. However, I am usually incrementally changing things. That makes a huge difference.
I started porting the MFC application to Qt just after the LGPL version of Qt was released, but before the LGPL release of 'qtwinmigrate' (get it at ftp://ftp.qt.nokia.com/qt/solutions/lgpl/). At the time, I thought Qt was going to hold on to the MFC migration stuff as an incentive for the commercial license.
I had to convert a good number of files before ever being able to compile the project. Once the very basics were up and running, I slowly re-added dialogs until the functionality matched the original version. This was much harder than being able to keep your existing MFC app running as is and slowly replacing dialogs.
So, the point is... USE QTWINMIGRATE!
Oh yeah... and don't use VC6. Upgrade to something more recent.