Making Qt-Application dynamic by runtime interpretation?
-
Hi! (spoiler: I am not a professional programmer ;) )
I have a little problem:
In my Qt-application, I want to be able to import widgets, I created in another program and show them.
But changing the widget, should change some properties of objects in my program. The problem here is, that the main application shall not know, what widget it will get to be able to import any kind of widget at runtime for full unlimitation.
From my experience, this is not possible in C++, unless the main program knows, what different widgets it could get. But I want to be able to create to create any widget.
Rewriting the programs in Python seems to be the only option with Qt so far, since Python is runtime interpreted and does not need to know, what widgets it will get because of that. But when I take a look into the list of implemented (and documented!) classes in PySide2, I don't think, I can create a QGraphicsView with a QGraphicsScene, containing QGraphicsItems and all other stuff, I use in the main program in Python just as I did in C++.First question: with which assumptions am I right, which are wrong?
Second: Have you any Idea, how I could implement that?Please tell me, what information is missing for a senceful answer, I will edit the question.
And the performance is not a major factor. The program is not that complex, that a Python-implementation would slow it down drastically (I guess).Thank you for answers!
-
Hi, as a general rule, if C++ can't do it, then you need to move to a lower, not higher level of programming.
Python uses text files interpreted by a program and guess what language that program is written in?! CSo I don't think what you are trying to do is possible unless you implement some serious hacks
-
Hi! (spoiler: I am not a professional programmer ;) )
I have a little problem:
In my Qt-application, I want to be able to import widgets, I created in another program and show them.
But changing the widget, should change some properties of objects in my program. The problem here is, that the main application shall not know, what widget it will get to be able to import any kind of widget at runtime for full unlimitation.
From my experience, this is not possible in C++, unless the main program knows, what different widgets it could get. But I want to be able to create to create any widget.
Rewriting the programs in Python seems to be the only option with Qt so far, since Python is runtime interpreted and does not need to know, what widgets it will get because of that. But when I take a look into the list of implemented (and documented!) classes in PySide2, I don't think, I can create a QGraphicsView with a QGraphicsScene, containing QGraphicsItems and all other stuff, I use in the main program in Python just as I did in C++.First question: with which assumptions am I right, which are wrong?
Second: Have you any Idea, how I could implement that?Please tell me, what information is missing for a senceful answer, I will edit the question.
And the performance is not a major factor. The program is not that complex, that a Python-implementation would slow it down drastically (I guess).Thank you for answers!
@Niagarer said in Making Qt-Application dynamic by runtime interpretation?:
import any kind of widget at runtime for full unlimitation.
Is it QUiLoader what you're looking for?
The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths
-
@Niagarer said in Making Qt-Application dynamic by runtime interpretation?:
import any kind of widget at runtime for full unlimitation.
Is it QUiLoader what you're looking for?
The QUiLoader class enables standalone applications to dynamically create user interfaces at run-time using the information stored in UI files or specified in plugin paths
@VRonin said in Making Qt-Application dynamic by runtime interpretation?:
So I don't think what you are trying to do is possible unless you implement some serious hacks
:,(
Hi, as a general rule, if C++ can't do it, then you need to move to a lower, not higher level of programming.
Well, makes sence but I am confused anyway. If Python is runtime interpreted and can take and evaluate any command I give it (over the command line) at any time at runtime, why can't it take Widget, evaluate it and show it on the screen at runtime?
@Pablo-J.-Rogina
Well, thank you, this sounds very interesting!
But I think, there is no way to evaluate the widgets' content here at runtime, right (f.ex. calling a function/slow in my program after changed something specific in the widget)? Because the importing program does not know, what it will get at compiletime. -
Hi! (spoiler: I am not a professional programmer ;) )
I have a little problem:
In my Qt-application, I want to be able to import widgets, I created in another program and show them.
But changing the widget, should change some properties of objects in my program. The problem here is, that the main application shall not know, what widget it will get to be able to import any kind of widget at runtime for full unlimitation.
From my experience, this is not possible in C++, unless the main program knows, what different widgets it could get. But I want to be able to create to create any widget.
Rewriting the programs in Python seems to be the only option with Qt so far, since Python is runtime interpreted and does not need to know, what widgets it will get because of that. But when I take a look into the list of implemented (and documented!) classes in PySide2, I don't think, I can create a QGraphicsView with a QGraphicsScene, containing QGraphicsItems and all other stuff, I use in the main program in Python just as I did in C++.First question: with which assumptions am I right, which are wrong?
Second: Have you any Idea, how I could implement that?Please tell me, what information is missing for a senceful answer, I will edit the question.
And the performance is not a major factor. The program is not that complex, that a Python-implementation would slow it down drastically (I guess).Thank you for answers!
@Niagarer said in Making Qt-Application dynamic by runtime interpretation?:
From my experience, this is not possible in C++, unless the main program knows, what different widgets it could get.
Correct.
Rewriting the programs in Python seems to be the only option with Qt so far
It's not the only option (for example, you could use QML + JavaScript too), but it's a feasible option.
when I take a look into the list of implemented (and documented!) classes in PySide2, I don't think, I can create a QGraphicsView with a QGraphicsScene, containing QGraphicsItems and all other stuff, I use in the main program in Python just as I did in C++.
Those are definitely documented: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QGraphicsView.html