Realtime Update of QLineEdit tools
-
I am looking for a way to Update a group of QEditLine tools. using signals and slots to notify me when the data has changed and update the tool. There is a way fjor Views to update when the database changes so there must be a way for Edit tools as well.
If anyone has any suggestions i would appreciate it.
Thanks
jdc -
I am looking for a way to Update a group of QEditLine tools. using signals and slots to notify me when the data has changed and update the tool. There is a way fjor Views to update when the database changes so there must be a way for Edit tools as well.
If anyone has any suggestions i would appreciate it.
Thanks
jdc -
@dencla
QLineEdit
s are widgets. Don't know what "tools" is about, norQEditLine
. Either look at QDataWidgetMapper or just attach slots to gosetText()
in response to your signals.@JonB Thanks for the feedback. Sorry for the type-o.
I meant QLineEdit sorry and tools are just multiple LineEdit instances.
I can update the tools->setText as you say, but what I am looking for is a way to automatically update the tool when the outside data changed from say a PLC or something where there is no user interaction at the time.I am using a timer event signal and slot now to do the update.
When I update a value in the database remotely my views update with out having to write any code. I was wondering if there is a way to do the same thing with other Classes like QLineEdit.
jdc -
@JonB Thanks for the feedback. Sorry for the type-o.
I meant QLineEdit sorry and tools are just multiple LineEdit instances.
I can update the tools->setText as you say, but what I am looking for is a way to automatically update the tool when the outside data changed from say a PLC or something where there is no user interaction at the time.I am using a timer event signal and slot now to do the update.
When I update a value in the database remotely my views update with out having to write any code. I was wondering if there is a way to do the same thing with other Classes like QLineEdit.
jdc@dencla said in Realtime Update of QLineEdit tools:
I can update the tools->setText as you say, but what I am looking for is a way to automatically update the tool when the outside data changed from say a PLC or something where there is no user interaction at the time.
I am using a timer event signal and slot now to do the update.Speaking of "tools" is still confusing in this case.
I was wondering if there is a way to do the same thing with other Classes like QLineEdit.
Have a look at Qt's data models and the views, as described here
-
@JonB Thanks for the feedback. Sorry for the type-o.
I meant QLineEdit sorry and tools are just multiple LineEdit instances.
I can update the tools->setText as you say, but what I am looking for is a way to automatically update the tool when the outside data changed from say a PLC or something where there is no user interaction at the time.I am using a timer event signal and slot now to do the update.
When I update a value in the database remotely my views update with out having to write any code. I was wondering if there is a way to do the same thing with other Classes like QLineEdit.
jdc@dencla
I am still struggling to discern your actual question. It now seemsQLineEdit
is a minor detail, are you asking about: if something else external updates data in a SQL database can your application "see" this and act on it, updating the UI, is that the real query?When I update a value in the database remotely my views update with out having to write any code. I
What do you mean here? What does "remotely" mean? IF you are claiming that something external updates a SQL database and your views immediately update in response, that is simply not true/possible with Qt. The views only change in response to changes in the in-memory model. If that is not updated from the database the view will not update. And the model can only be updated if you explicitly, or something implicitly, issues a SQL
SELECT
statement to re-read from the database. Either your database provider does not offer any "push" notifications to your application on remote data changes or at least there is no interface to such from the Qt model classes. As you have noted, the only way to achieve something is to re-query on a timer event from your application, which is not ideal. Unless you can arrange for whatever is happening which updates the database to raise a signal in your application you are stuck.If you do (somehow) get to update the in-memory data model I have said that
QDataWidgetMapper
can be used to immediately reflect changes to a number ofQLineEdit
s without you writing code/signals for each one individually if that is what you want. Did you look at that? -
@dencla
I am still struggling to discern your actual question. It now seemsQLineEdit
is a minor detail, are you asking about: if something else external updates data in a SQL database can your application "see" this and act on it, updating the UI, is that the real query?When I update a value in the database remotely my views update with out having to write any code. I
What do you mean here? What does "remotely" mean? IF you are claiming that something external updates a SQL database and your views immediately update in response, that is simply not true/possible with Qt. The views only change in response to changes in the in-memory model. If that is not updated from the database the view will not update. And the model can only be updated if you explicitly, or something implicitly, issues a SQL
SELECT
statement to re-read from the database. Either your database provider does not offer any "push" notifications to your application on remote data changes or at least there is no interface to such from the Qt model classes. As you have noted, the only way to achieve something is to re-query on a timer event from your application, which is not ideal. Unless you can arrange for whatever is happening which updates the database to raise a signal in your application you are stuck.If you do (somehow) get to update the in-memory data model I have said that
QDataWidgetMapper
can be used to immediately reflect changes to a number ofQLineEdit
s without you writing code/signals for each one individually if that is what you want. Did you look at that?@JonB You are correct in your first assumption about the QLineEdit. Also I was referring to the memory model database examples inadvertently.
I will review the link that you sent me. I have looked at that before, but I have to admit, I'm not well versed in the qt functions yet.
I have not explored the QDataWidgetMapper, that may be the answer to my question. In the future I will be wanting to receive data from an OPC server which is part of the direction of the question.
Thanks for your feedback it is helpful and I will explore your suggestions.jdc
-