how do something on a window before the user open that window?
-
@davidlabib
I have explained in the clearest language possible, I cannot think of another way to phrase it. -
@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 yourdoAll(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. -
@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 -
@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. -
@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? -
@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.
-
@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? -
@davidlabib
I think you're saying you want all the other other widgets to be enabled/disabled depending on whetherAdmin Password
has or has not been filled in correctly? Or according as it has something/nothing already in it?If that is the case you will want to disable/enable as user types into
Admin Password
? So you will also want to call this during input to that widget? Do you also (sometimes) put something intoAdmin Password
when you display the dialog?All in all, why do you only seem to want to call
doAll()
when window is shown? And you need to answer @mrjj's question: Yes, we can see your dialog, but that does not tell us whether you keep it in existence after showing it or whether you destroy it and construct from scratch?I'll give you one tip. I have code which must only be executed the first time a window/dialog is shown, not before then (construction time is too early) and not after then. So my code for
showEvent()
is like (I don't use C++):classMemberVarialbeFirstShown = false; showEvent() { if not classMemberVarialbeFirstShown doFirstImeStuff(); classMemberVarialbeFirstShown = true; }
-
@mrjj no , i don't have to keep it in existence
i don't mind destroying and re-creating it -
@davidlabib
Ok so im not sure what its not working for you
If you call doAll(false) in constructor
then when Dialog is shown they should all be disabled.
Is that not the case? -
@davidlabib
Then you could follow @mrjj's advice to just do your work in the constructor and not worry about show events.But you really need to explain precisely when you want those widgets to change between enabled & disabled, because I for one don't know what you intend.
-
the default is disabled
but when the user input admin password correct it will enabled the widgets
my problem is to make the widgets disabled by default
if i put doAll(false) in the constructor when soneone fill admin password correct it will enable
but if the user closed editUser and open it again it will be enabled without admin password filling -
@davidlabib
but when the user input admin password correct it will enabled the widgets
When? Do you re-verify the password as he types each character into the line edit?
my problem is to make the widgets disabled by default
Put the disablement into the constructor.
if i put doAll(false) in the constructor when soneone fill admin password correct it will enable
It will not enable unless you tell it to.
but if the user closed editUser and open it again it will be enabled without admin password filling
That is the bit where @mrjj was suggesting you destroy the dialog after using it, and re-create a new one each time it's wanted. Then there is no "open again" from wherever it got to, you always start afresh in the constructor.
-
- Yes , verify the password
- I don't know how to destroy the dialog after the user close the window
-
@davidlabib
1.Yes , verify the password
That does not answer my question. When do you verify the password? As the user types a character at a time (really?)? After he has finished typing (how do you know that?)?
2.I don't know how to destroy the dialog after the user close the window
How do you create the dialog in the first place? With
new
? -
-
the form will enable after the user type all the character correctly without clicking buttons
after he type the last char correct it will enable the window -
by qt designer form class
-
-
@davidlabib said in how do something on a window before the user open that window?:
after he type the last char
how do you know that? What if user enters correct password but then he/she enters one more character?
"by qt designer form class" - this is not the answer to the question. The question is: how do you create the dialog INSTANCE.
Like this:MyDialog *dialog = new MyDialog(this);
?