Solved Reloading certain widgets present on stacked widgets after pressing buttons
-
@jsulm Can I reload some functions only??
-
@Thank-You I still don't understand what you want to reload and why.
Why is it not enough to simply show the page?
"Can I reload some functions only??" - what functions? Can you please explain your use case? -
I have a database in folder.
in writeData we can add new user
and in viewData we can view added userSo main problem is
when I add new user from writeData and go to viewData
the new user is not shown at that time.
But when I reopen the application that user is shownSo I guess you will understand "What I want to do here"??
If you did not understand please ask me one more time
-
@Thank-You You should take a look at https://doc.qt.io/qt-5/model-view-programming.html
If you don't want to use the above you can still load the data (not the ui!) in https://doc.qt.io/qt-5/qwidget.html#showEvent of your pages.
-
@jsulm I tried to use
ui->readData->repaint();
ui->readData->update(0,0,ui->readData->width() , ui->readData->height());It didn't work
Is it wrong method -
@Thank-You said in Reloading certain widgets present on stacked widgets after pressing buttons:
It didn't work
Of course it did not work! How should it? repaint/update simply retriggers a paint, it does not magically read your database.
You need to read the data from the database and add it to your ui, not just repainting.
So, fir example if you show second page and need to add data which was added on first page dovoid mainwindow::on_view_clicked(){ // Read the data from the database and add it to the widgets on second page ui->mainApp->setCurrentIndex(2); }
-
@jsulm Is there any method to reload whole widget??
Like as of calling constructor -
@Thank-You said in Reloading certain widgets present on stacked widgets after pressing buttons:
Is there any method to reload whole widget??
If I understood you correctly you want to add data from database to your widget which was added to the database previously in another page, right? So, you do not reload the widget, you add data to it. Also, you should mention what widget that is and how you fill it with data. There is no magic, you have to read the database and add the data to the widget.
If you want to do it properly then please read https://doc.qt.io/qt-5/model-view-programming.html and check the examples.
-
@Thank-You said in Reloading certain widgets present on stacked widgets after pressing buttons:
Is there any method to reload whole widget??
Like as of calling constructormove everything you do in the constructor into its own function, call that function from the constructor and every time you want to "reload" your page
-