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. How i can handel changes in my application
Forum Updated to NodeBB v4.3 + New Features

How i can handel changes in my application

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 1.9k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    advseo32
    wrote on last edited by
    #1

    Hi, every body

    i have a problem for choosing a solution to handle changes in my application

    means: when the user make some thing or change some thing in the application , and try to eixt the program

    i will pop up a message to inform him that , he has some changes

    i decided to use a boolean global variable , but i don't know that this way is correct

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tabi
      wrote on last edited by
      #2

      Can you post code snippet?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Global variables are almost never a correct solution, if you ask me.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Tabi
          wrote on last edited by
          #4

          Make a bool flag in class and a method modified() that only can set flag true. Whenever data change signal emitted in its connected slot call modified. In slot of close check flag if set then inform user.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            advseo32
            wrote on last edited by
            #5

            [quote author="Tabi" date="1380631138"]Can you post code snippet?[/quote]

            I speak, in general way

            [quote author="Tabi" date="1380632644"]Make a bool flag in class and a method modified() that only can set flag true. Whenever data change signal emitted in its connected slot call modified. In slot of close check flag if set then inform user. [/quote]

            Yes this is what i mean, but if this is the right way

            [quote author="Andre" date="1380631804"]Global variables are almost never a correct solution, if you ask me.[/quote]

            So, what the correct solution ??

            1 Reply Last reply
            0
            • CAD_codingC Offline
              CAD_codingC Offline
              CAD_coding
              wrote on last edited by
              #6

              AFAIK, re-implement the close event for your Main Window.
              This is what I have done in my application.
              You have to maintain a private class variable or a static class variable for your Main Window class. I have used a bool variable which is a private class variable, since there are multiple windows in my application.

              What you have to do is maintain the value of this variable all throughout your application so that whenever close button is pressed by the user, you will check the value of the variable in the re-implemented function. If there is a change then show a message & ignore the close event. Else accept it.

              You can tinker around the help in Qt Creator for the exact code & understanding how to implement it.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                advseo32
                wrote on last edited by
                #7

                Ok, i will try this methode , thanks a lot

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Tabi
                  wrote on last edited by
                  #8

                  http://qt-project.org/doc/qt-5.0/qtwidgets/richtext-textedit-textedit-cpp.html check out the implimentation of bool TextEdit::maybeSave() function. It is similar as CAD_coding explained.

                  HTH.

                  1 Reply Last reply
                  0

                  • Login

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