Separate logic from GUI elements
-
If i well understood your intention. I suggest you to start with "QThread class":http://qt-project.org/doc/qt-4.8/qthread.html and use signals and slots to communicate between thread with some logic and gui.
-
Hi,
There's no real tutorial about that matter. It's more about designing your core logic so that it doesn't depend on your widgets. e.g. the Model/View paradigm where you have part of the business logic in the model and you can change the view on top of without any problem.
-
Starting with thread is not really a good idea. Threading is a complex matter that should not be mixed in when learning how to decouple widgets and core logic.
-
you can try reading
http://qt-project.org/doc/qt-4.8/modelview.html -
One more option is to read about "MVVM":http://en.wikipedia.org/wiki/Model_View_ViewModel
"One more reading":http://imaginativethinking.ca/mvvm101
"And one more":http://msdn.microsoft.com/en-us/magazine/dd419663.aspx/There is no direct implementation of MVVM in Qt though.
-
Hi,
Please share a bit about your background with us, so that we can better understand how to answer your question:
Where did you get this idea from? Why do you want to decouple GUI from logic?
Have you developed projects in other languages before? If so, what languages are they?
Do you already have a Qt program where the logic is not separated from the GUI?
I think the easiest way to learn is to take a program that you've already written (point #3) and re-write it to separate logic from GUI. You can post your code here for us to look at and share tips.
-
Hi all,
If i understand your question correctly...
I think that searching about "inter-process communication" and "shared memory" can be useful.
you can split your app in two part:
Master(contain logic which it share result in part of memory)
and
Slave(contain GUI which it read and set data from shared memory)
i am waiting for your answer... -
Hi a.jafarabadi,
[quote author="a.jafarabadi" date="1414044298"]
I think that searching about "inter-process communication" and "shared memory" can be useful.
you can split your app in two part:
Master(contain logic which it share result in part of memory)
and
Slave(contain GUI which it read and set data from shared memory)[/quote]I don't think this is appropriate. "Inter-process communication" (IPC) and "shared memory" are for 2 different programs to communicate with each other.Andre005 is asking about separating the GUI from the logic within one single program. This does not require IPC or shared memory.
-
Oh, excuse me friends,
but he can see my comment as a suggest :)
thanks. -
Hi,
thx for support guys.
[quote author="mrjj" date="1413981770"]you can try reading
http://qt-project.org/doc/qt-4.8/modelview.html
[/quote]This link is a good start to cover the method an the background of this topic.
[quote author="JKSH" date="1414041964"]
Where did you get this idea from? Why do you want to decouple GUI from logic?
Have you developed projects in other languages before? If so, what languages are they?
Do you already have a Qt program where the logic is not separated from the GUI?
.[/quote]
I had listen to a course of software design. In this course they used java to explain the patern and it was used the related toolchain for that. They used adapter function to link the model with the GUI elements.
With QT and C++ i think it is a sophisticated framework to lear some GUI programming and it gives a gool result in a short time and it ist similar to approach of that course
In my former project i have only work on embedded systems, where GUI programming is not the focus.
As a QT programm you can take a look in this post:
http://qt-project.org/forums/viewthread/48602/
With this simple example, it could be discuss the separation of the Button functionality and the way (algo) the grid is build.
Regards,
Andre