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 do something on a window before the user open that window?

how do something on a window before the user open that window?

Scheduled Pinned Locked Moved Solved General and Desktop
35 Posts 5 Posters 6.2k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    how to disable some parts on a window before it appear ti the user?

    1 Reply Last reply
    0
    • 6thC6 Offline
      6thC6 Offline
      6thC
      wrote on last edited by
      #2

      You could delay load (incubate) or only createComponent when you require, you could set visible: false

      Do you want to give more details on your environment QML / Widgets and clarify your question. There's many solutions - do you know what you want.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        @6thC

        0_1534372890493_8b468099-ac15-4ecf-a0e0-10354b64e801-image.png
        this work just for the first time
        i want every time the user opens this window it will doAll(false)

        1 Reply Last reply
        0
        • 6thC6 Offline
          6thC6 Offline
          6thC
          wrote on last edited by
          #4

          You have established editUsers CTOR calls correctly doAll(false); , correct?
          Do you know the signal you're interested in? - maybe this http://doc.qt.io/qt-5/qwidget.html#visible-prop ?

          Not really sure what the issue is - seems like you've already done the hard work? Can you elaborate.

          ? 1 Reply Last reply
          1
          • 6thC6 6thC

            You have established editUsers CTOR calls correctly doAll(false); , correct?
            Do you know the signal you're interested in? - maybe this http://doc.qt.io/qt-5/qwidget.html#visible-prop ?

            Not really sure what the issue is - seems like you've already done the hard work? Can you elaborate.

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by A Former User
            #5

            @6thC forget about disabling some parts
            what i did in the photo runs just one time
            which mean if i open this window it will execute doAll()
            but if i closed the window and open it again it will not execute doAll()
            i will have to exit the whole application to execute it again
            what i want is that every time the user open this window it will execute doAll()
            did you understand me ?

            1 Reply Last reply
            0
            • 6thC6 Offline
              6thC6 Offline
              6thC
              wrote on last edited by
              #6

              I understand you - do you understand me. You've proven it works in the constructor right? So now you just need to call this method again but not at construction time, during another stage of it's life. You currently only have it wired/hooked into object creation time - where you are is the constructor and that only happens when an class is instantiated as an object.

              So. close and open ... probably aren't doing Destruct and Construct. They may be reusing your object and just changing objects states.

              You could:

              • call the method again - hooked into the events that you care about
              • use a new editUsers object

              I don't think you will need to close your whole application at all, that's just crazy. There will be a focus event or something to use, did you go to the link in the last?

              1 Reply Last reply
              3
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                @6thC yes i understand you,
                but the problem is there is no events related with the window opening
                and doAll() must execute in the window opening before any thing else
                i think that qt have it own methods on opening the windows or showing it

                1 Reply Last reply
                0
                • 6thC6 Offline
                  6thC6 Offline
                  6thC
                  wrote on last edited by
                  #8

                  did you go to http://doc.qt.io/qt-5/qwidget.html#visible-prop ?

                  "See also show(), hide(), isHidden(), isVisibleTo(), isMinimized(), showEvent(), and hideEvent()."

                  There's a number of events that may be suitable. I cannot tell from just this definition - could you just use a fresh editUsers instance? I'm sure there's a way to hook this.

                  What about http://doc.qt.io/qt-5/qdialog.html#showEvent

                  1 Reply Last reply
                  2
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by A Former User
                    #9

                    @6thC thank a lot,
                    0_1534415349311_f773974e-c947-403e-b6e5-344c612e8b8e-image.png
                    it worked

                    JonBJ 1 Reply Last reply
                    1
                    • ? A Former User

                      @6thC thank a lot,
                      0_1534415349311_f773974e-c947-403e-b6e5-344c612e8b8e-image.png
                      it worked

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #10

                      @davidlabib
                      You will have read http://doc.qt.io/qt-5/qwidget.html#showEvent & http://doc.qt.io/qt-5/qshowevent.html by now I presume. So just checking you are happy that your doAll(false); will be executed when, say, the window is minimized and then restored? Not just when the user shows the window. So, for example, if your doAll(false) resets widget visibility you will get that on minimize + restore too.

                      ? 1 Reply Last reply
                      0
                      • JonBJ JonB

                        @davidlabib
                        You will have read http://doc.qt.io/qt-5/qwidget.html#showEvent & http://doc.qt.io/qt-5/qshowevent.html by now I presume. So just checking you are happy that your doAll(false); will be executed when, say, the window is minimized and then restored? Not just when the user shows the window. So, for example, if your doAll(false) resets widget visibility you will get that on minimize + restore too.

                        ? Offline
                        ? Offline
                        A Former User
                        wrote on last edited by
                        #11

                        @JonB 1. I don't understand you , please explain

                        JonBJ 1 Reply Last reply
                        0
                        • ? A Former User

                          @JonB 1. I don't understand you , please explain

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #12

                          @davidlabib
                          I have explained in the clearest language possible, I cannot think of another way to phrase it.

                          ? 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @davidlabib
                            I have explained in the clearest language possible, I cannot think of another way to phrase it.

                            ? Offline
                            ? Offline
                            A Former User
                            wrote on last edited by
                            #13

                            @JonB do you say that in this way if the user minimized the window and then restored it
                            it will execute doAll(false) or the reverse ?

                            JonBJ 1 Reply Last reply
                            0
                            • ? A Former User

                              @JonB do you say that in this way if the user minimized the window and then restored it
                              it will execute doAll(false) or the reverse ?

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by
                              #14

                              @davidlabib
                              I wrote:

                              So just checking you are happy that your doAll(false); will be executed when, say, the window is minimized and then restored?

                              How can I explain that more clearly? If the user minimizes your window and then restores it (makes it visible again) showEvent() will be called. And as you have written it that means it will call your doAll(false). Why don't you try it on minimizing and then restoring your window?

                              I don't know what your doAll(false) does. Maybe it wants to do that, maybe it does not.

                              1 Reply Last reply
                              0
                              • ? Offline
                                ? Offline
                                A Former User
                                wrote on last edited by A Former User
                                #15

                                @JonB now I understand you ,
                                I'm sorry for stupidity ,but english is not my tongue
                                I'm using dialog not Mainwondow that's why i didn't try to minimizing and then restoring the window

                                JonBJ 1 Reply Last reply
                                0
                                • ? A Former User

                                  @JonB now I understand you ,
                                  I'm sorry for stupidity ,but english is not my tongue
                                  I'm using dialog not Mainwondow that's why i didn't try to minimizing and then restoring the window

                                  JonBJ Offline
                                  JonBJ Offline
                                  JonB
                                  wrote on last edited by
                                  #16

                                  @davidlabib
                                  I realise about the English, not a problem, I just did not know how to phrase it any better.

                                  Just check: when the dialog is up, got to your desktop's toolbar (or whatever) and see if you can minimize/restore from there (e.g. Windows allows click on toolbar icon to toggle minimize/restore). If it lets you do that while dialog is showing, see whether your showEvent() in the dialog gets called? If not, you are probably good to go.

                                  1 Reply Last reply
                                  0
                                  • ? Offline
                                    ? Offline
                                    A Former User
                                    wrote on last edited by
                                    #17

                                    @JonB you are right
                                    when i minimize and restore it execute doAll(false)
                                    is there is another event work when the window opens but not sensitive about minimizing and restoring?

                                    mrjjM JonBJ 2 Replies Last reply
                                    0
                                    • ? A Former User

                                      @JonB you are right
                                      when i minimize and restore it execute doAll(false)
                                      is there is another event work when the window opens but not sensitive about minimizing and restoring?

                                      mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      @davidlabib
                                      Hi
                                      Do it in constructor as you show - should call it only once and
                                      then not again on show /minimize etc.
                                      But normally you create a Dialog show it and delete it
                                      so constructor is called every time and hence it should be exactly like u want.

                                      So please show the code where you pop up the editUser Dialog.

                                      1 Reply Last reply
                                      1
                                      • ? A Former User

                                        @JonB you are right
                                        when i minimize and restore it execute doAll(false)
                                        is there is another event work when the window opens but not sensitive about minimizing and restoring?

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by
                                        #19

                                        @davidlabib
                                        We can look into the minimize/restore if we need to. However for now you should answer @mrjj's comment. Why are you re-showing the dialog? Are you keeping it in existence permanently and hiding/showing it (in which case, why?), or do you destroy and re-create it, in which case you could do your code in constructor instead?

                                        1 Reply Last reply
                                        1
                                        • ? Offline
                                          ? Offline
                                          A Former User
                                          wrote on last edited by
                                          #20

                                          @mrjj @JonB
                                          this is my dialog
                                          0_1534424096209_336e2a13-d316-471c-8b82-b5c8b2f80d91-image.png

                                          this is doAll()
                                          0_1534424167621_f244dbec-bdff-46a1-b9a4-1582fd9e8325-image.png

                                          it suppose to execute doall(true) when admin password is right .OK?
                                          so doAll must be false when the window shows
                                          so the user will be have to fill admin password

                                          JonBJ 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