Integrating CLIPS with Qt - c++

I've been trying to build a GUI with Qt. However, I have no idea how to integrate CLIPS with the signals and slots of Qt.
For example, in the GUI if a user presses ctrl+r it should run the source file entered. Similarly, the agenda has a different window which updates as the rules are loaded. How can I integrate all of this with Qt?
I'm also open to any ideas you may have about building a frontend for CLIPS.
Thanks

Take a look at CLIPSShell on SourceForge: https://sourceforge.net/projects/clipsshell/. It's written in Qt.

Related

Bring QProcess window to front (running Qt Assistant)

My Qt application starts a QProcess that runs Qt Assistant.
I am using Linux (Ubuntu/Neon/KDE) but I want the Qt application to run on Windows and other Linux distributions as well.
Now I need a function that allows to bring the Assistant main window to front at the desktop.
I could not find a solution doing this using the QProcess object. Also I could not find a way to do this via Qt Assistant remote control.
How can I do this in a portable way?
If all you need is showing qhc help files along with your application, you can have a look at the Qt Help module, which is used by Assistant itself.
Instead of showing the help in an external application like the Qt
Assistant, it is also possible to embed the online help in the
application. The contents can then be retrieved via the QHelpEngine
class and can be displayed in nearly any form. Showing the help in a
QTextBrowser is probably the most common way, but embedding it in
What's This help is also perfectly possible.
More here

How to create an Evernote kind of widget for global menu of a MacOS/X desktop using QT?

How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.

Any way to forward drag/drop events to embedded process window?

A bit of background:
I need to embed a webview of some kind into a Qt application (that embeds python/PyQt) in order to display some html content. I am stuck with the MinGW build of Qt because that is what the Windows version of our software is built with and it is not feasible to migrate over to Visual C++. Unfortunately for me, QtWebKit has been removed from recent versions of Qt and its replacement, QtWebEngine, is not supported by the MinGW builds of Qt.
It appears my remaining options are one of
Maintain a custom build of Qt that reincludes the old QtWebKit code.
Embed some other rendering engine.
Launch a web browser in a separate process and embed its window in the main program.
I have looked into the first two options, and both sound like a bit of a PITA with a combination of outdated/abandoned code, and complicated build processes with patchy/outdated/conflicting documentation, and limited Windows support.
I've decided to explore the option of embedding a web browser process into my application. I've been successful at getting a firefox process embedded in PyQt using QWindow::fromWinId and QWidget::createWindowContainer
self.process = QtCore.QProcess()
self.process.setProgram('C:/Program Files (x86)/Mozilla Firefox/firefox.exe')
self.process.start()
time.sleep(1)
hwnd = get_window_handle(self.process.processId())
ext_win = QtGui.QWindow.fromWinId(hwnd)
widget = QtWidgets.QWidget.createWindowContainer(ext_win)
widget.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.ForeignWindow)
self.layout().addWidget(widget)
I can drag and drop html files into the embedded firefox window and they load just fine. I thought I might be able to exploit this feature by faking drag/drop events in order to programatically load files.
def fakeDragDropEvent(self, urls):
point = QtCore.QPoint(self.width()/2, self.height()/2)
self.mimedata = QtCore.QMimeData()
self.mimedata.setUrls(urls)
dragevent = QtGui.QDragEnterEvent(point, QtCore.Qt.CopyAction, self.mimedata, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier)
app.postEvent(self, dragevent)
time.sleep(0.1)
dropevent = QtGui.QDragEnterEvent(point, QtCore.Qt.CopyAction, self.mimedata, QtCore.Qt.LeftButton, QtCore.Qt.NoModifier)
app.postEvent(self, dropevent)
These fake events can be picked up by the main window etc when I implement event handlers and set acceptDrops(True), however they seem to have no effect on the embedded process window.
Is there any way to make my embedded process window pick up these events? Or do I maybe need to program the drag/drop events using the native Windows API instead?
I'm also open to any other suggestions about how I can display html in my application.

Filling text in qwidget using win32 api

I have a problem. I am using C++ to develop an application in Win32 that among other scopes automatize some user input process in an external app in order for the user to be ready to operate.
Particularly I would like to use Win32 API to fill some text in a Qt QWidget control. I wrote a DLL in pure C to get this task done. I tested it on a MFC application and it works very well.
Anyway I could not get it to work for Qt QWidget controls.
I was able to get the right handle via the EnumChildWindows function (stored in the struct Field).
SendMessage(Field.hFound,WM_SETTEXT,(WPARAM)NULL,(LPARAM)_T("bla bla bla"));
But the SendMessage doesn't seem to work because maybe the control (most probably a QLineedit) supports other messages to get this job done.
Is there any specification for these events, I googled a lot but I could not find anything suitable.
What is the most straightforward way to get this code working? Is there an Event table mapping for Qt I could use? Do I have to use some Qt headers and link it against a DLL (this could be a problem because of licensing)?
Thanks in advance.
Qt, at least 4.8 and 5.x, uses foreign controls. None of the widgets, beyond the window, have native handles. Your EnumChildWindows is most likely not finding what you think it's finding.
If you don't have access to the Qt application's source code, there's nothing else you can do, short of injecting your own code into the running application. If the application is dynamically linked, you can figure out what version of Qt it's using, and what compiler it was compiled with, and the likely set of Qt configuration options. You can then compile your own code with the same compiler and using same Qt version, and inject it into the running application. You can then enumerate visible windows, and their children, and find the control you're after.

2 threads - one with opengl window and the second with wxwidgets one

I'm writing an editor and I have a problem which means calling native file save/open dialog from my opengl app. The editor is written with my in-game opengl gui. So i came up with idea that when user press "load" or "save", I will create a thread which will create required (non-visible) wx window and it will call wxFileDialog and after the job is done I will delete that thread. Is it possible or maybe there are better aproaches to acces file open/save dialog in cross platform way from an opengl app?
wxWidget has a OpenGL widget. Put your OpenGL stuff into this one, forward the event received by the widget to your GUI system, then you'll not have to battle for the event loop.
As others have already said, the simplest solution is to use wxWidgets for the main loop and wxGLCanvas for OpenGL stuff.
But if this is impossible, for some reason, you should indeed be able to use wxWidgets from another thread. Just remember that wxWidgets GUI functionality can only be used from a single thread so you need to initialize it from that thread too. And, of course, you'll need to handle thread synchronization yourself as wxWidgets won't know anything about the rest of your program.
If you are using GLUT, or equivalent, then you do NOT have a cross-platform framework. If you want a cross-platform app, then your will have to choose a framework ( e.g wxWidgets or Qt or whatever ) and proceed from there. Otherwise, you can use the native calls to the windows API if you are on windows, and the equivalent on other platforms.
GLUT only gives you a console style application. If you want a GUI, then you have to choose a GUI framework, even if you do not want cross-platform. There as many to choose from, the choice mostly depends on which you are most familiar with. Then you add the calls to the OpenGL library from you GUI application, however built. This way, you do not have to muck around with multiple threads.
It may be that you have a massive investment in your GLUT application, and do not wish to discard it merely to get a few GUI capabilities. In this case, I recommend building a new GUI app, separate from your GLUT application, which communicates with your existing app using a socket ( or other interprocess com system ) but runs in a separate process. This way you will not encounter all the ghastly, hard to fix bugs, created by multithreaded apps.