Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Reloading certain widgets present on stacked widgets after pressing buttons
Forum Updated to NodeBB v4.3 + New Features

Reloading certain widgets present on stacked widgets after pressing buttons

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jsulmJ jsulm

    @Thank-You said in Reloading certain widgets present on stacked widgets after pressing buttons:

    I want to reload whole page

    What does "reload" mean here?
    What exactly do you want to reload?

    Thank YouT Offline
    Thank YouT Offline
    Thank You
    wrote on last edited by
    #3

    @jsulm I want to reload whole ui
    From example
    I want to reload whole readData widget

    Let's make QT free or It will go forever

    TRUE AND FALSE <3

    1 Reply Last reply
    0
    • jsulmJ jsulm

      @Thank-You said in Reloading certain widgets present on stacked widgets after pressing buttons:

      I want to reload whole page

      What does "reload" mean here?
      What exactly do you want to reload?

      Thank YouT Offline
      Thank YouT Offline
      Thank You
      wrote on last edited by
      #4

      @jsulm Can I reload some functions only??

      Let's make QT free or It will go forever

      TRUE AND FALSE <3

      jsulmJ 1 Reply Last reply
      0
      • Thank YouT Thank You

        @jsulm Can I reload some functions only??

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @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?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Thank YouT 1 Reply Last reply
        0
        • jsulmJ jsulm

          @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?

          Thank YouT Offline
          Thank YouT Offline
          Thank You
          wrote on last edited by
          #6

          @jsulm

          I have a database in folder.

          in writeData we can add new user
          and in viewData we can view added user

          So 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 shown

          So I guess you will understand "What I want to do here"??

          If you did not understand please ask me one more time

          Let's make QT free or It will go forever

          TRUE AND FALSE <3

          jsulmJ 1 Reply Last reply
          0
          • Thank YouT Thank You

            @jsulm

            I have a database in folder.

            in writeData we can add new user
            and in viewData we can view added user

            So 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 shown

            So I guess you will understand "What I want to do here"??

            If you did not understand please ask me one more time

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            Thank YouT 1 Reply Last reply
            2
            • jsulmJ jsulm

              @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.

              Thank YouT Offline
              Thank YouT Offline
              Thank You
              wrote on last edited by
              #8

              @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

              Let's make QT free or It will go forever

              TRUE AND FALSE <3

              jsulmJ 1 Reply Last reply
              0
              • Thank YouT Thank You

                @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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @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 do

                void mainwindow::on_view_clicked(){
                // Read the data from the database and add it to the widgets on second page
                ui->mainApp->setCurrentIndex(2);
                }
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                Thank YouT 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @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 do

                  void mainwindow::on_view_clicked(){
                  // Read the data from the database and add it to the widgets on second page
                  ui->mainApp->setCurrentIndex(2);
                  }
                  
                  Thank YouT Offline
                  Thank YouT Offline
                  Thank You
                  wrote on last edited by
                  #10

                  @jsulm Is there any method to reload whole widget??
                  Like as of calling constructor

                  Let's make QT free or It will go forever

                  TRUE AND FALSE <3

                  jsulmJ J.HilkJ 2 Replies Last reply
                  0
                  • Thank YouT Thank You

                    @jsulm Is there any method to reload whole widget??
                    Like as of calling constructor

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #11

                    @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.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    2
                    • Thank YouT Thank You

                      @jsulm Is there any method to reload whole widget??
                      Like as of calling constructor

                      J.HilkJ Online
                      J.HilkJ Online
                      J.Hilk
                      Moderators
                      wrote on last edited by
                      #12

                      @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 constructor

                      move 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


                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                      Q: What's that?
                      A: It's blue light.
                      Q: What does it do?
                      A: It turns blue.

                      Thank YouT 1 Reply Last reply
                      3
                      • J.HilkJ J.Hilk

                        @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 constructor

                        move 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

                        Thank YouT Offline
                        Thank YouT Offline
                        Thank You
                        wrote on last edited by
                        #13

                        @J-Hilk Yes as soon as @jsulm said about filling certain data
                        I used that method
                        I created function which include all the things previously mentioned in constructor
                        and called before setting things.
                        So anyone coming here should do what @jsulm suggested using @J-Hilk method

                        Thank You

                        Let's make QT free or It will go forever

                        TRUE AND FALSE <3

                        1 Reply Last reply
                        2

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved