You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, June 3rd 2013, 7:34am

on_QLineEdit_CursorPositionChanged

Hello All, I am new to Qt and I am trying to make a program where when i click the lineedit , a pop up box would show up below . I am able to do that by using

Source code

1
2
void MainWindow::on_NRIC_cursorPositionChanged(int arg1, int arg2){popupKeyboard();//Showing the popup keyboard
}



But after i close the popup and click on the QLineEdit , The popup does not show at all .

There is another problem , When the text fill is filled with letters,Whenever I press Enter on the popup menu, it would take many clicks to close


Source code

1
2
3
4
5
6
7
8
 QFrame* popupNumpadBed = new QFrame(this, Qt::Tools| Qt::FramelessWindowHint);
     popupNumpadBed->resize(600,500);
     popupNumpadBed->setAttribute( Qt::WA_TranslucentBackground ); 
 QPushButton *BedEnter= new QPushButton(  popupNumpadBed );
BedEnter->setText("Enter");
    BedEnter->setGeometry(450,256.66666, 150, 53.33333);
  BedEnter->setFocus();
  connect(BedEnter, SIGNAL(clicked()), popupNumpadBed, SLOT(hide()));


Please Help thank you

pele1410

Trainee

  • "pele1410" is male

Posts: 127

Location: Lafayette, LA

  • Send private message

2

Friday, June 14th 2013, 3:07pm

If I had to guess, the reason it will not show up twice initially is that the first time you click in it, the cursor is set to position 0. When you close the popup and press it again, the cursor position is still at 0, so the position did not change (hence the slot not being called).

For your second issue, every time a letter is entered, the cursor position is changed so your slot is called. Without seeing your popupKeyboard () function, I'd guess you're creating a new popup everytime? So you're not closing the same popup multiple times, but closing multiple popups.

You can solve the second problem by checking inside of popupKeyboard to see if a popup is already open.

But as a much broader solution, I would subclass QLineEdit, and implement the mousePressEvent. In that function you could emit a signal that triggers a slot in whatever class this code is from.
"Without imperfection, you or I would not exist." ~Stephen Hawking

Used tags

QLineEdit