Custom QWidget Keyboard first time click issue.
-
Yes.
after that when I click on Anywhere on Widget Nothing happen or no Any event gets called. -
@Arvind-K
so the widget appear frozen for a moment ?
Do you have any kind of loops in constructor or anything like that ?No, there is no Loop in the constructor or No Any other code only I have connected signal to Slot.
Keyboard::Keyboard(QWidget *parent) :
QWidget(parent),
ui(new Ui::Keyboard)
{
ui->setupUi(this);this->setWindowFlags(Qt::WindowStaysOnTopHint); connect ( ui->Buttonq, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonw, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttone, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonr, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttont, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttony, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonu, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttoni, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttono, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonp, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttona, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttons, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttond, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonf, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttong, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonh, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonj, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonk, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonl, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonz, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonx, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonc, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonv, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonb, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonn, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonm, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button0, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button1, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button2, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button3, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button4, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button5, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button6, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button7, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button8, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button9, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->space, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); outputText = ""; shift = false;
}
-
No, there is no Loop in the constructor or No Any other code only I have connected signal to Slot.
Keyboard::Keyboard(QWidget *parent) :
QWidget(parent),
ui(new Ui::Keyboard)
{
ui->setupUi(this);this->setWindowFlags(Qt::WindowStaysOnTopHint); connect ( ui->Buttonq, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonw, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttone, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonr, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttont, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttony, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonu, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttoni, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttono, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonp, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttona, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttons, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttond, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonf, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttong, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonh, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonj, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonk, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonl, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonz, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonx, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonc, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonv, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonb, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonn, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Buttonm, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button0, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button1, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button2, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button3, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button4, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button5, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button6, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button7, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button8, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->Button9, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); connect ( ui->space, SIGNAL( clicked() ), this, SLOT( keyboardHandler() ) ); outputText = ""; shift = false;
}
-
As I mentioned Previously when I set WindowModality of Keyboard widget to QApplicationModal I face this First Click issue otherwise it works fine. but if I didn't set windowModality then Keyboard goes back to the parent widget.
**lineEditkeyboard->setWindowModality(Qt::ApplicationModal); **
-
As I mentioned Previously when I set WindowModality of Keyboard widget to QApplicationModal I face this First Click issue otherwise it works fine. but if I didn't set windowModality then Keyboard goes back to the parent widget.
**lineEditkeyboard->setWindowModality(Qt::ApplicationModal); **
Hmm.
The code looks ok fine and i cant see any reason for
QApplicationModal to cause this effect but
it could be a bug in Qt. -
@Arvind-K
ok. when this situation is happening.
Does the buttons show activated effect ?
I mean can u see u pres them or anything ? -
@Arvind-K
Ok, then it seems its stuck for a moment in the event loop.
Im not sure what to do about that.
setWindowModality(Qt::ApplicationModal) must use a local even loop to make
it modal so might be a but with this or something i dont see in the code.