PDA

View Full Version : QLintEdit and keyPressEvent problem



impeteperry
5th November 2008, 01:21
I have 7 QLineEdits in a QHBoxLayout. Each of these QLineEdits are activated for "User" input by the user pressing a "Function Key"/"PushButton".
Each one of the lineEdit are configuree the same
boxLayout = new QVBoxLayout ( frameD );
inputStripLayout = new QHBoxLayout ( );
boxLayout->addLayout ( inputStripLayout );

lbCategory = new QLabel(" Category #");
lbCategory->setFont ( fb );
inputStripLayout->addWidget ( lbCategory );

leCNum = new QLineEdit();
leCNum->setAlignment ( Qt::AlignCenter );
leCNum->setPalette ( palE );
leCNum->setFont ( fb );
leCNum->setMaximumWidth(30);
leCNum->setEnabled(false);
inputStripLayout->addWidget ( leCNum);

leCName = new QLineEdit();
leCName->setAlignment ( Qt::AlignCenter );
leCName->setPalette ( palB );
leCName->setFont ( fb );
leCName->setText ( "Category" );
inputStripLayout->addWidget ( leCName );

lbGroup = new QLabel(" Group #");
lbGroup->setFont ( fb );
inputStripLayout->addWidget ( lbGroup );

leGNum = new QLineEdit();
leGNum->setAlignment ( Qt::AlignCenter );
leGNum->setPalette ( palE );
leGNum->setFont ( fb );
leGNum->setMaximumWidth(30);
leGNum->setEnabled(false);
inputStripLayout->addWidget ( leGNum);

leGName = new QLineEdit();
leGName->setAlignment ( Qt::AlignCenter );
leGName->setPalette ( palB );
leGName->setFont ( fb );
leGName->setText ( "Group" );
inputStripLayout->addWidget ( leGName );
etc.
All seven activate the following when the "enter/return" key is pressed
/// slotGetUserInput
void BaseForm::slotGetUserInput ( QString caller )
{
index = caller;
emit setMessageBox("base 724 index = " + index);
if(index == "CNum")
textItem = leCNum->text();
else if(index == "CName")
textItem = leCName->text();
else if(index == "GNum")
textItem = leGNum->text();
else if(index == "GName")
textItem = leGName->text();
else if(index == "DNum")
textItem = leDNum->text();
else if(index == "DName")
textItem = leDName->text();
else if(index == "SNum")
textItem = leSNum->text();

}
but only the first two activate
/// slotFromKeyboard-
void BaseForm::slotFromKeyboard()
{
QStringList tempList;
QString k;

inputText = textItem;

emit setMessageBox("base 749 inputTtxt:\n" + textItem);
}
The "pushbutton is similar for all lineEdits[I know I am missing somthing but haven't been able to find it. Please Help

caduel
5th November 2008, 07:10
you need to give us some information to do so.

show us the "glue":
* what are those pushbuttons you are referring to?
* how do you connect signals to slots?

impeteperry
5th November 2008, 14:10
I have attached (i hope) a snapshot of the user interface I want to use for a "DiscGear" disc storage device. I am experimenting with a modified "command line " type interface to eliminate the "learning curve" The pushbuttons are all similar
/// Pb5-------------------------------------------------------------------------------------/// Pb5
void BaseForm::slotPb5() // call "help" function
{
if (Pb5->text() == "~") return; /// the button is blank, no action
leCName->clear();
leCName->setEnabled(true);
leCName->setFocus();
emit setupFunction("CName");
return;

}
and
/// Pb7-------------------------------------------------------------------------------------/// Pb7
void BaseForm::slotPb7() // call "help" function
{
if (Pb7->text() == "~") return; /// the button is blank, no action
leGName->clear();
leGName->setEnabled(true);
leGName->setFocus();
emit setupFunction("GName");
return;
}both access
void BaseForm::slotSetupFunction(QString item)
{
emit setMessageBox("base 564 we is here from " + item);
emit getUserInput(item);
}
Pb5 activates the "key press event" but Pb7 does not.

Nuts, the attachment didn't work. Apparently I have used up my allotment of attachments and I don't know how to get rid of the old ones. I need help here also.

thanks.

spirit
5th November 2008, 14:44
could you prepare a compilable example which represent the trouble?

impeteperry
5th November 2008, 17:23
If I could get rid of the old attachments, I could attach an example, but in essence, there are a row of QLineEdits with row of keyboard Fn numbers below. When the "User" presses a Fn key, the QLineEdit widget above it gets the "focus". He then keys in some text and presses the enter/return key. The function keys can be pressed in any order. The problem is that the program only gets the text from the first two QLineEdits. I hope this helps

spirit
5th November 2008, 17:26
how do you think this can help us? ;) if you need a help than you should show us compilable code. :)

impeteperry
7th November 2008, 18:34
I do not have comparable code. I am trying to develop a user friendly program interface.
I go back to command line programming, where the program told the user, with prompts, what the user had to key in. The program reads what the user had keyed in and did it's thing. Simple Simple Simple.

Here I have seven options available to the user. He can select any option by pressing the appropriate function key. When he presses one a "help Box" opens up with instructions specifically for the selected item. The user then enters the information asked for in th QLineEdit. and presses the return/enter key and the program takes it from there. THAT IS ALL THERE IS TO IT.

The problem is the program only gets the information from the first two QLineEdit boxes.

I know I can do the same thing with an option menu, but that is not what I want to do.

Since I have two of them working and five of them not working with the SAME CODE I am
perplexed.

If somebody would tell me how to erase the Attachments I have used in earlier posts, I could use one here, you would see where I'm coming from. Thanks

spirit
8th November 2008, 06:34
what is the aim of using inputting information trought GUI to a console app?
PS. attachment manager is located "User CP"->"Miscellaneous"->"Attachments".

impeteperry
2nd December 2008, 17:58
Well, I tried to write a simple program to demonstrate my problem. Well in doing so, I discovered my problem. I was mis-using the "keyPressEvent". Now to revise my program.
I want to thank you all for trying to help a stupid old man.