[Solved]How can I launch a QWizardPage with a key?
-
do you know the english expression?
As far as I can tell, the one you quoted is a perfectly valid English expression.
Nevertheless when I do it in the HW, as I said, I'm in WP1 with PB1 focused, then press Esc and the QMessageBox appears but it does not have a focus, neither its buttons and I can see the focus on PB1 (But can't move or do anything with TAB as it should if I where in WP1)... dunno if i explain it well.. if it is not clear please let me know.
This is very strange. I don't know what's happening or why the focus is not transferred to the message box. It sounds silly, but did you update your HW program with the last one (with the last code)? Also you could try setting a parent to the message box (substitute
NULL
forthis
in the constructor) and see if that works better (it won't be able to leave the main window area, but hopefully this won't be a problem). You could try also to set all the default properties that the button should have (although this doesn't seem like a good approach, but if it works ...):yesButton->setFocus(Qt::OtherFocusReason); yesButton->setAutoDefault(true); yesButton->setDefault(true);
Additional note (not related to the focus):
Don't useQString::fromUtf8
like you're doing, what you had before (tr("some text")
) was perfectly fine.Kind regards.
-
@kshegunov said:
As far as I can tell, the one you quoted is a perfectly valid English expression.
Ok.. as you said it was something spanish I thought that thas a bad-literal translation...
It sounds silly, but did you update your HW program with the last one (with the last code)?
Yes it might seem silly but it isn't.. so many problems came from here but in this case it is silly because as I've got a lot of problems (releases that doesn't update well.. and so on), what I do every time is deleting the old release and then generate the new one and also I always check the date and time of the file...
I forgot to add on my last post that I also tried with that:
yesButton->setFocus(); yesButton->setFocusPolicy(Qt::TabFocus);
And I've tried with your last lines and still its the same... the focus is stuck in the PB1... u.u'' I'm trying everything I think but nothing.... what a problem (I ran out of time and all those little gnomes/mushrooms/code strange problems doesn't help me so much) xD
Don't use QString::fromUtf8 like you're doing, what you had before (tr("some text")) was perfectly fine.
Which is the difference between "text" and tr("text") ? In my case I have to use QString::fromUtf8 because its the only way I can use accents in my text and ofc my app is in spanish... I just switch it to english to post it here so it will be more understandable to everyone who reads this topic :) So my code its something like QString::fromUtf8("ConfirmaciĆ³n");
Kind regards for you too!! :D hehe
-
Also you could try setting a parent to the message box (substitute NULL for this in the constructor) and see if that works better (it won't be able to leave the main window area, but hopefully this won't be a problem).
What about this? I'm really running out, or more correctly have run out, of ideas ...
Which is the difference between "text" and tr("text") ?
"text"
is of typeconst char * const
- a string literal, whiletr("text")
takes the string"text"
and looks it up into the translation tables to create aQString
from it that's translated to the currently set language. However, your next explanation seems like a valid reason to useQString::fromUtf8
instead, since you don't appear to be using the translation framework.Kind regards.
-
@kshegunov said:
try setting a parent to the message box
Sorry didn't saw it. Tried and its the same, the only thing that changes is that, as the default text is red in the parent, the QMessageBox's text is red too. but still the samebehaviour with PB1 focused... the QMessage appears like if you put a stick there....
I'm really running out, or more correctly have run out, of ideas ...
Wow! I thought that would never be possible!! :D Haha you had a lot of different ideas :D My next thought is: how could I do this confirm message without using QMessagebox or QDialog (I still dunno why do you call it "modal").. I'm trying to think how to do it if those classes didn't exist.. but not sure about the options...
"text" is of type const char * const - a string literal, while tr("text") takes the string "text" and looks it up into the translation tables to create a QString from it that's translated to the currently set language.
I think I understand you but do you know any clear example? I think that you mean that if it has to change any letter it will o it but not sure
However, your next explanation seems like a valid reason to use QString::fromUtf8 instead, since you don't appear to be using the translation framework.
Are you sure? Oh wow I did something fine! hahahaha (I'm trying to be positive xd)
Note: I've tried also with:
box.setFocus(); box.setFocusPolicy(Qt::PopupFocusReason);
ofc nothing works...
-
My next thought is: how could I do this confirm message without using QMessagebox or QDialog (I still dunno why do you call it "modal").. I'm trying to think how to do it if those classes didn't exist.. but not sure about the options...
Because they are modal, i.e. they don't allow the user to interact with other windows from your application. Modeless dialogs on the other hand can lose the focus and the user can interact with other widgets.
On your second question:
You could use a generic widget, however I really doubt that anything will change. Something like this:QWidget * dialogWidget = new QWidget(this); dialogWidget->setAttribute(Qt::WA_DeleteOnClose, true); //< Takes care to delete the widget when it's closed. dialogWidget->setWindowModality(Qt::WindowModal); //< Makes the widget modal // Initialize with a form: Ui::MessageFormUi dwUi; dwUi.setupUi(dialogWidget); // Connect buttons as appropriate here ... // And finally, show the widget dialogWidget->show();
I think I understand you but do you know any clear example? I think that you mean that if it has to change any letter it will o it but not sure
No I don't have an example on hand, you could try the translation framework's documentation, it should be explained there.
Kind regards.
-
@kshegunov I've see something curious...maybe it helps or enlight someone... As I said the program is going to run only with keyboard but I can connect a mouse on my tests so I did it to see what happened. If I mouseover the Yes/No buttons they get the focus and if I click on them they do what they have to do....
What I can't understand is why:
- in the Pc you see: the program normal > press Esc > then it appears more obscured like with fog so you see clearly the QMessageBox and center your vision on it and the focus dissapears from PB1 to the Yes button
- in the HW: the program normal > press Esc> then ... it appears as a moment before, with the PB1 focused, not obscured, no changes... but with the QMessageBox in the middle like a stick and like if the program where frozen (but it isn't as I can use mouse and click on Yes/no buttons).
I'll try now your example with a widget and tell you something as soon as possible :)
No I don't have an example on hand, you could try the translation framework's documentation, it should be explained there.
Ok don't worry I'll search it later :D
Thank you!
EDIT:
-
My mate told me that there is no window manager in the HW (this is one of the dlls they took off....) so maybe this is the problem.. but I still have to find a solution to my problem...
I've tried usingbox.grabKeyboard();
with QMessageBox and guess what? Still the same behaviour .. BUT if you press Y (of Yes) it closes the program and if you press N (of No) it closes the QMessageBox... Its something but its really ugly and not a final solution as there is no focus on the buttons and the users can't guess that (Even if I write something as: Do you want to quit? Press Y if yes, N if don't" -
About your widget solution... I must be missing something because it does not show up.... I did add new>qt form>QWidget>named it MessageFormUi.ui >runqmake> added #include "ui_MessageFormUi.h" but then I can't use the
Ui::MessageFormUi *ui;
I had to useUi::Form *ui
... I couldn0t use MessageFormUi... I copy the code snippet.. its just the same as yours but it doesn't show up (connections will come later if it is shown on screen)
QWidget * dialogWidget = new QWidget(this); dialogWidget->setAttribute(Qt::WA_DeleteOnClose, true); //< Takes care to delete the widget when it's closed. dialogWidget->setWindowModality(Qt::WindowModal); //< Makes the widget modal // Initialize with a form: Ui::Form dwUi; dwUi.setupUi(dialogWidget); // Connect buttons as appropriate here ... dialogWidget->show();
Thanks and regads!
-
You should use a QDialog if you expect your widget to act as dialog.
-
@SGaist said:
You should use a QDialog if you expect your widget to act as dialog.
Hi Sgaist, thanks for your reply. I tried it too with the next code:
QDialog dialog(this, Qt::Dialog | Qt::CustomizeWindowHint); Ui::Dialog ui; ui.setupUi(&dialog); int result = dialog.exec(); if (result == QDialog::Accepted) close();
And it shows up BUT I'm still having the same problem... in the HW the focus is not passed from WP to this dialog and I can't focus the Yes/No buttons...
-
My mate told me that there is no window manager in the HW
I'm really doubtful of this, I believe your mate is feeding you misinformation.
but I still have to find a solution to my problem...
It might be impossible.
About your widget solution... I must be missing something because it does not show up....
Or possible I've missed something, as I'd never tried that. Honestly, I've never heard of such problem as yours with the dialogs, and have never experienced something similar myself.
Unfortunately, I have nothing further to suggest.
Kind regards.
-
@kshegunov Well.. we have decided to use the dialog and tell the user to press Y or N to exit or not and this issue about the focus will be a future bug to fix... (hope this 'future time' never cames... ) XD
Thank you so much for ALL your help and patience ^^ @kshegunov and @SGaist Really grateful :D
I'll try to solve the other problems (posted in this forum too) about going back 2 pages and the key buffer issue :)
-
Well.. we have decided to use the dialog and tell the user to press Y or N to exit or not and this issue about the focus will be a future bug to fix
I think this a practical decision.
Thank you so much for ALL your help
Anytime. Take care!
Kind regards.