Results 1 to 9 of 9

Thread: QLintEdit and keyPressEvent problem

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QLintEdit and keyPressEvent problem

    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
    Qt Code:
    1. boxLayout = new QVBoxLayout ( frameD );
    2. inputStripLayout = new QHBoxLayout ( );
    3. boxLayout->addLayout ( inputStripLayout );
    4.  
    5. lbCategory = new QLabel(" Category #");
    6. lbCategory->setFont ( fb );
    7. inputStripLayout->addWidget ( lbCategory );
    8.  
    9. leCNum = new QLineEdit();
    10. leCNum->setAlignment ( Qt::AlignCenter );
    11. leCNum->setPalette ( palE );
    12. leCNum->setFont ( fb );
    13. leCNum->setMaximumWidth(30);
    14. leCNum->setEnabled(false);
    15. inputStripLayout->addWidget ( leCNum);
    16.  
    17. leCName = new QLineEdit();
    18. leCName->setAlignment ( Qt::AlignCenter );
    19. leCName->setPalette ( palB );
    20. leCName->setFont ( fb );
    21. leCName->setText ( "Category" );
    22. inputStripLayout->addWidget ( leCName );
    23.  
    24. lbGroup = new QLabel(" Group #");
    25. lbGroup->setFont ( fb );
    26. inputStripLayout->addWidget ( lbGroup );
    27.  
    28. leGNum = new QLineEdit();
    29. leGNum->setAlignment ( Qt::AlignCenter );
    30. leGNum->setPalette ( palE );
    31. leGNum->setFont ( fb );
    32. leGNum->setMaximumWidth(30);
    33. leGNum->setEnabled(false);
    34. inputStripLayout->addWidget ( leGNum);
    35.  
    36. leGName = new QLineEdit();
    37. leGName->setAlignment ( Qt::AlignCenter );
    38. leGName->setPalette ( palB );
    39. leGName->setFont ( fb );
    40. leGName->setText ( "Group" );
    41. inputStripLayout->addWidget ( leGName );
    To copy to clipboard, switch view to plain text mode 
    etc.
    All seven activate the following when the "enter/return" key is pressed
    Qt Code:
    1. /// slotGetUserInput
    2. void BaseForm::slotGetUserInput ( QString caller )
    3. {
    4. index = caller;
    5. emit setMessageBox("base 724 index = " + index);
    6. if(index == "CNum")
    7. textItem = leCNum->text();
    8. else if(index == "CName")
    9. textItem = leCName->text();
    10. else if(index == "GNum")
    11. textItem = leGNum->text();
    12. else if(index == "GName")
    13. textItem = leGName->text();
    14. else if(index == "DNum")
    15. textItem = leDNum->text();
    16. else if(index == "DName")
    17. textItem = leDName->text();
    18. else if(index == "SNum")
    19. textItem = leSNum->text();
    20.  
    21. }
    To copy to clipboard, switch view to plain text mode 
    but only the first two activate
    Qt Code:
    1. /// slotFromKeyboard-
    2. void BaseForm::slotFromKeyboard()
    3. {
    4. QStringList tempList;
    5.  
    6. inputText = textItem;
    7.  
    8. emit setMessageBox("base 749 inputTtxt:\n" + textItem);
    9. }
    To copy to clipboard, switch view to plain text mode 
    The "pushbutton is similar for all lineEdits[I know I am missing somthing but haven't been able to find it. Please Help

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QLintEdit and keyPressEvent problem

    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?

  3. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QLintEdit and keyPressEvent problem

    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
    Qt Code:
    1. /// Pb5-------------------------------------------------------------------------------------/// Pb5
    2. void BaseForm::slotPb5() // call "help" function
    3. {
    4. if (Pb5->text() == "~") return; /// the button is blank, no action
    5. leCName->clear();
    6. leCName->setEnabled(true);
    7. leCName->setFocus();
    8. emit setupFunction("CName");
    9. return;
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. /// Pb7-------------------------------------------------------------------------------------/// Pb7
    2. void BaseForm::slotPb7() // call "help" function
    3. {
    4. if (Pb7->text() == "~") return; /// the button is blank, no action
    5. leGName->clear();
    6. leGName->setEnabled(true);
    7. leGName->setFocus();
    8. emit setupFunction("GName");
    9. return;
    10. }
    To copy to clipboard, switch view to plain text mode 
    both access
    Qt Code:
    1. void BaseForm::slotSetupFunction(QString item)
    2. {
    3. emit setMessageBox("base 564 we is here from " + item);
    4. emit getUserInput(item);
    5. }
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by impeteperry; 5th November 2008 at 14:16.

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLintEdit and keyPressEvent problem

    could you prepare a compilable example which represent the trouble?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QLintEdit and keyPressEvent problem

    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

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLintEdit and keyPressEvent problem

    how do you think this can help us? if you need a help than you should show us compilable code.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QLintEdit and keyPressEvent problem

    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

  8. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLintEdit and keyPressEvent problem

    what is the aim of using inputting information trought GUI to a console app?
    PS. attachment manager is located "User CP"->"Miscellaneous"->"Attachments".
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  9. #9
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QLintEdit and keyPressEvent problem

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.