C++/Lua: Implement Qt/QtLua with QWebView - c++

I'm planning to write a cross-platform project in C++, which will run a Lua engine. I'd like to write the main program for that project including the GUI in Lua. And to make it even easier, I want to write the GUI in HTML and therefore I need an additional library, hopefully QtLua which is based on Qt.
From what I heard, implementing QtLua into the Lua engine shouldn't be too hard and Qt has a nice class called QWebView that should allow me to write HTML GUIs. But I'm wondering about 2 things:
Is it cross-platform capable?
Is QWebView even part of QtLua?

Answers to both questions i think you should find here http://www.nongnu.org/libqtlua/
There's this part that says
QtLua is not designed to develop an application in pure Lua but rather to extend a Qt C++ application using Lua as scripting language.
Therefore, if your application is built/based on Qt and only extended using Lua, it should be cross-platform capable.
And for your second question; QWebView is used to view and edit web content, QtLua or QtScript is used to provide support for application scripting. QWebView is not part of QtLua plus i don't see any member of the QWebView class that has any connection with scripting

Related

Can Qt show OSX Finder Choose File Dialog (QFileDialog::getOpenFileName) from an OSX dylib?

I'm making a Qt/C++ dylib on OSX. How can I get it to call QFileDialog::getOpenFileName() when there is no widget context?
(Background: See, what I'm doing here is building a minimalist Objective C Cocoa application that will load my Qt/C++ dylib to do most of the work. This allows me to use the OSX native webkit (something not provided by Qt/C++ in 5.5). I prefer working in Qt/C++ than Objective C. So, that's why I'm interested.)
The answer according to Simon Warta and Nicholas Smith is no -- it requires a widget context in Qt to drive that dialog from Qt. Since there isn't one in this case, I would have to drive certain tasks, which require such a context, from Objective C instead. However, Nicholas Smith also says that it's a better programming strategy to drive the GUI from Objective C in such a case, and drive the rest from Qt/C++ for the heavy lifting tasks such as database stuff, etc.
Since I'm building a project that uses Webkit mostly for the GUI and may only need something minor outside that for GUI, such as open a Finder file dialog, it's actually not going to be that much Objective C. The rest I can drive from Qt/C++, since I prefer that more.

How to add custom class processing functionality in Qt

I'm a little new to Qt. I have been programming in C++ for quite a while.
I want to create an application in Qt/C++ just because it's very easy to create the GUIs. I wanted to know that is it possible that I can write a C++ class in native C++ and use it in my Qt application.
I want to write the GUI in Qt and do all processing using my native C++ code rather than Qt/C++. Is it possible to compile a DLL in native C++ and then load and use it in QtC++ application?
I really want to write a GUI application using C++.
There is no such thing as "native C++" as opposed to "Qt/C++", so the question makes little sense. All of core Qt code is compiled native C++, just as any C++ application that uses Qt is.
As JBentley has duly noted:
[You may be] confused because of the code generating tools Qt uses, like moc [or uic]. Those don't mean that C++ compiles natively while Qt doesn't. All those tools do is provide a convenient way to produce a lot of boiler code that the framework relies on, so that the programmer can pretend they don't exist and use things like Qt's slots and signals. The final code which you compile and link is ordinary C++, with calls into the Qt library (also C++) which you've used.
If what you're asking is "am I forced to use Qt classes in all parts of my application", then no - nobody's forcing you to do that. If you already have parts of your application written using boost, or standard C++ library classes, it's fine.
You have to understand that Qt has modular design and provides a lot of non-GUI functionality. You can use the non-gui modules in the non-gui part of your code. It's a fairly clean and general purpose application development framework. It's perfectly fine to use it for various internet server applications, for example.
The following Qt modules are of note for non-gui development:
Core: Core non-graphical classes: containers, event loop, timers, threads, state machines, internationalization, XML, json, file I/O - all of it portable.
Network: Classes to make network programming easier and more portable. Includes secure sockets, HTTP requests, etc.
SQL: Classes for database integration using SQL.
You are able to use any C++ code you would like. I have have actually had questions with the same thought process in my day to day work. First you need to grok the idea that Qt uses normal C++ and special tools to create a robust set of libraries.
Later on come back and you will want to learn more about the items below:
Signals and Slots
This is how events are wired together.
One objects sends a signal and all connected slots get called with the given parameters.
Signals and slots are an example of the Observer Pattern.
Designer Forms
The form designer lets you lay out controls using simple drag and drop operations.
The .ui file gets transformed into C++ code as part of the build process.
Layouts
You can do a lot of things with just the horizontal, vertical and grid layouts
Spacers
You can push things up, down, left, or right using different types of spacers
They look like a spring on the form designer.
Resource Files
Lets you embed graphics and other content directly into the application.
Models, Views and Delegates
Hard to avoid if your have a non trivial UI
There are other things too, but knowledge in these areas will let you make some decent desktop applications. My favorite reference is older, but still a goodie: "C++ GUI Programming with Qt4" http://www.amazon.com/Programming-Edition-Prentice-Software-Development/dp/0132354160
Yes QT4 is "old" and QT5 has been out for some time... but the book provides a solid foundation that you will be able to add information to.

Best Practise for GUI development for vanilla C++ application

I want to know about developing of gui to vanilla C++ application. I have experience in mostly in command line application. My experience in C++ gui till now is cout and cin. I have some experience in WPF (just to mention that I do have some gui experience) I hope this will describe my level of experience with gui. Now,I want to develop an application which needs separate GUI with possibility of 3D display. Of course, one of the choice for GUI API is Qt.Also,after reading lots of stuff on internet, i think code separation would be really helpful in future.
So, here goes my question: Is it possible if I keep my logic as generic as possible (not using winapi or qt in my logic) and make only GUI part API specific (say winapi or qt). Or I will need to add some code in my logic section, say for synchronization between logic and GUI. One can say signal and slot from qt is possible but as far as i know signals and slots are qt specific. they are not standard C++.
In summery,my question is can i make my logic in standard C++ (to stay platform/ framework independent) and only design platform specific GUI? If yes, could you please suggest a link or tutorial or book. A sample code or implementation would be 'a wish come true'. Also, some insights in code separation tactics would be quite helpful.
Regards!!
EDIT::
I will elaborate my problem. I have an application which has separate GUI and Logic section. The gui uses WinAPI and as the communication mode used is windows messages, previous user has created a HWND object in Logic which communicates to GUI. So, there is a HWND in Logic and HWND in GUI. I don't find this approach satisfying. One of the reason is that Logic part will be edited by non-programmers in later stage (not much. just modification of constants or changing implementation of function without changing para or return value). So, I just want to keep logic part in standard format (as much as possible). So once again, could anyone help me in designing business logic in C++ and GUI in any API.
After reading some threads, I found that answering own question is not a bad practice. So I will share the answer I have got.
There is no standard way to build a C++ gui application without using external dependencies. The synchronization between gui and logic part is always framework specific. So, if I want to develop a C++ gui application, I cannot put logic part in standard C++. It must have some code from external framework which will communicate the logic part and gui part. Having said that, I have found my way in by following method. I am going to put my logic part inside a static lib and then I will attach this lib to gui part. It will increase coding in gui section, but it will keep the base functions in standard c++. This way (a function lib in standard C++ and machine operation in framework specific code) will work for me. I hope I am on right track. :)
You can to a large extent write completely separate logic and GUI code in Qt. However you will be able to create a much more useful GUI if you allow the logic and GUI code to interact. Qt has it's own classes for a lot of things (QString, QVector<> etc.) but you're free to ignore these for the most part and use the standard library instead if you'd prefer.
However, I do not think that it is worth trying to separate Qt from the logic code entirely because, as mentioned before, you will be able to build a much better GUI if they interact. For a simple example you could write a very simple Qt GUI with just a window and a button; press that button and some logic code is run. However with more interaction you could use signals and slots to update a progress bar on the GUI to let the user know how far the logic code had got. Also Qt is very portable, allowing you to build your program for Windows, Mac and at least some Linux distros.
Also for your 3D display requirement I recently found myself trying to do a similar thing and found this example very useful - http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html.
I think that by default, you should aim to separate business logic from presentation (GUI) code. In web development, the most commonly used pattern is MVC, and it's principles apply equally to native applications.
However, this separation might be more difficult to achieve in native applications. Mainly because there are no frameworks such as Symfony, which have already solved these architectural problems, and make it easy to keep UI and business code separate by following the established conventions. I have't used Qt but from what I know it's mainly a GUI toolkit - models, views and controllers are not as well-defined and integrated.
Depending on the nature of the needed interface, a simple OpenGL GUI might suffice. This is what I did for a simple uni project. The project needed to display a shapefile colored according to statistics in an XML file. I created a number of GUI widgets - button, label etc, and a custom map widget which encapsulates "business logic". Perhaps I should have "cleansed" the map widget, making it as generic as possible, and move all business logic to a separate library, but considering the business layer was very thin I thought the added complexity would outweigh the benefits.
Another factor is your skill-set - current, and areas which you want to improve. I was more interested in OpenGL and freeglut, then in learning Qt. If I had known Qt, I would have used that.
I have done some projects with vanilla C++ and a QT GUI. The idea of not mixing any QT code into the pure C++ stuff is always good but takes a lot of fun out of it. Usually you end up with a much more elaborate GUI than you expected and would often like to connect it better/easier to your code. Signals and Slots are a really great way to let the GUI interact with your code, but then you start mixing...
TLDR: Think really hard about why you don't want to mix your code with e.g. QT. It would not meand mixing GUI and Logic, no way, but your life could be a lot easier using QT classes like QStrings, QProcesses or QThreads...
If you manage to do all the interactions using QTs Signal & Slot mechanism, at some point you might even change you native QT GUI to a QT Quick (QML) one, which is highly customizable, has nice looks and animations and whatnot.
This is just my opinion.

Windows 8, C++ and Metro GUI samples?

So I look at this (Windows build keynote 1:42:56) And I just do not get it - what I can use to create GUI from C++ and/or GUI language that will be capable to call functions from my C++ code? HTML, XAML or what? And where to see code sample of doing markup call code and code create GUI sample with C++ for Windows 8 Metro apps?
Sample code in C++ and other languages is at http://code.msdn.microsoft.com/windowsapps. You can take a look at how it's done.
If you want to call C++ code the easiest way will be to use C++ with Component Extensions. This is just plain C++ that compiles to native code however it has a few extensions (reminiscent of C++/CLI) that let you use the WinRT COM components without worrying quite so much about the COM plumbing.
With C++ and WinRT you can actually use XAML like the managed languages to define your user interface. It's pretty neat, see the documentation here:
Information on C++ component extensions
I haven't looked into it but you may still be able to use P/Invoke or COM interop in the managed languages to call C++ code for a Metro style app however this is unconfirmed. Obviously a desktop app can do all the things it normally would.
You can use C++ code to write metro style applications. You can also write applications in Javascript/HTML/CSS and call APIs that you write in C++ or C#/VB from those JavaScript applications.

Start Windows GUI Application Development With C++

I'm looking into creating a GUI program for Windows in C++, I have a good knowledge of C++ in the command line and also in game creation. But I'm not sure where to start with GUI application development.
I have Visual Studio 2010 and have created new projects with a GUI but these templates are complex and leaves me not understanding whats happening and how to modify it.
So I'm asking where do I start? Preferably good websites that you can recommend or tutorials, rather than books being a poor student :)
Having written Windows code since Win2.0, I have to say: start with C#. It's a very easy language to learn after C++, and many of the new features (like built-in event handling) were put there to make writing GUI applications easier.
Then, once you're used to the basic concepts of window management and messaging, then drop down into C++.
I say this for the same reason that assembly is not a good first language. There is an enormous amount of housekeeping code in a Windows application, and in C++ you see it all. Better to use a language that hides much of it until you're grounded.
I'd personally recommend using Qt instead to develop your GUI.
Use a GUI framework/library that hides the dirt from the low-level GUI api. MFC is not a solution - it is only a thin layer above the WinAPI. I recommend using QT or wxWidgets. If you use Qt use the Qt creator/Qt designer to design interfaces. If you use
wxWidgets use wxFormBuilder.