Page 1 of 4 123 ... LastLast
Results 1 to 20 of 66

Thread: linking of combox with lineEdit.

  1. #1
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default linking of combox with lineEdit.

    Hi. from the image. i would like to link the Combox with the lineEdit. as in i select End device 1, only the things in end device 1 would be change to whatever i type in the lineEdit. can anyone give me some example of code about doing it?
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    connect the singnal of combobox activated() to some slot in your dialog and play with lineedit

  3. #3
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    i know the connect part. but how about the play part?

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    but how about the play part?
    you have not explained very well what is the play part?
    only the things in end device 1 would be change to whatever i type in the lineEdit.
    what the heck anybody can understand by this?

  5. #5
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    i have attach an image what..

  6. #6
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    connect the singnal of combobox activated() to some slot in your dialog and play with lineedit
    you said play with lineedit.


    anyway. izzit possible when the combox is selected and the words in the lineedit is type. then i use qsTemp.sprintf to display the word in my GUI?

  7. #7
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    why cant you rephrase your question?
    do you whant to change the text in combobox to whatever u type in lineedit?


    EDIT..

    i still cant understat what is qTemp?

  8. #8
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by MrDeath View Post
    do you whant to change the text in combobox to whatever u type in lineedit?
    nope. okay i roughly explain what i am doing and what i want. first for the image there is a yellow node. they will be 8 of them. so my combobox i already set it to 8 choice. from "End Device 1 to 8"

    so now lets say when i select End device 1 on my combobox, and a type a certain word in the lineEdit. when i press ok. the word in the line edit will appear on the yellow node.

    i still cant understat what is qTemp?
    nvm just know it as printf.

  9. #9
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    do it like this..
    Qt Code:
    1. //main
    2. MyDialog dlg;
    3.  
    4. if(dlg.exe()==QDialog::Accepted)
    5. {
    6. int deviceId = dlg.getDeviceId();
    7. QString word = dlg.getWord();
    8. if(!word.isEmpty())
    9. putWordInUse(word);
    10. .....
    11. ...
    12. }
    13.  
    14. //MyDialog
    15. int MyDialog::getDeviceId()
    16. {
    17. return combobox->currentIndex()+1;//0+1=end device 1 ,1+1.....
    18. }
    19.  
    20. int MyDialog::getWord()
    21. {
    22. return lineEdit->text();
    23. }
    To copy to clipboard, switch view to plain text mode 

    do not forget to connect the ok button to accept() slot of QDialog

  10. #10
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    i dun think this will work with my current code. argh talking in forum is pretty hard man. i cant possible post my whole source code here.

    do you have a msn or something? so i could end you my whole program. and u help me take a look?

  11. #11
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    sorry man .. this is the best i can do...

  12. #12
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    oh man. i seriously need some help here. anybody?

  13. #13
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    no reply from anyone else?

  14. #14
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: linking of combox with lineEdit.

    I think that it is hard to give you some example because we don't know what is that yellow node. Is it some widget or what? A picture? Diagram in some other application? There are some signals in QLineEdit which you can use (like textChanged() ) so you can connect them to your slots, where you can check the current combo box selection and change proper node (yellow or any other you want). But how would I know how to change that yellow node? Paint it with QPainter or what?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  15. #15
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    do you have a msn or something? so i could end you my whole program. and u help me take a look?
    That's a bad idea, because then all other board members can't learn from your problem.

    Quote Originally Posted by Devoraz View Post
    no reply from anyone else?
    We live in different time zones, so sometimes we have to sleep


    And as to your question: It's also not very clear to me what you want to achieve: Change the yellow bubble text on the fly while typing in the line edit, or after the dialog has closed?

    For the first, emit a signal from the dialog whenever the text changes. catch that in your main window and manipulate the corresponding node.

  16. #16
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Lykurg View Post
    And as to your question: It's also not very clear to me what you want to achieve: Change the yellow bubble text on the fly while typing in the line edit, or after the dialog has closed?
    .
    after closing the dialog. i would need to use case method with the combobox i think? as there are 8 choice to select.

  17. #17
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by faldżip View Post
    I think that it is hard to give you some example because we don't know what is that yellow node. Is it some widget or what? A picture? Diagram in some other application? There are some signals in QLineEdit which you can use (like textChanged() ) so you can connect them to your slots, where you can check the current combo box selection and change proper node (yellow or any other you want). But how would I know how to change that yellow node? Paint it with QPainter or what?
    alright. the yellow node is drawn using Qpainter. and the text in the yellow node user "sprintf" to display.

  18. #18
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    after closing the dialog. i would need to use case method with the combobox i think? as there are 8 choice to select.
    After closing the dialog use QComboBox::currentIndex() or QComboBox::currentText() to determinate the box. Either use switch or if/else unless you don't have stored your nodes in a QList etc.

  19. #19
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: linking of combox with lineEdit.

    okay first of all. to kickstart. i suppose i have to connect the combobox to the qlineEdit right?

    i had look through the some examples and the QT Assistant. but i am still confuse of how to go about connecting it.

  20. #20
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: linking of combox with lineEdit.

    Quote Originally Posted by Devoraz View Post
    okay first of all. to kickstart. i suppose i have to connect the combobox to the qlineEdit right?

    i had look through the some examples and the QT Assistant. but i am still confuse of how to go about connecting it.
    Come on, what's the problem QCombobox::currentIndexChanged(const QString&) -> QLineEdit::setText()! REad about signal and slot mechanism.

Similar Threads

  1. Qt linking problem
    By LovesTha in forum Newbie
    Replies: 3
    Last Post: 31st March 2009, 00:31
  2. How to update lineEdit
    By HelloDan in forum Qt Programming
    Replies: 9
    Last Post: 17th February 2009, 08:01
  3. Copy / Paste doesn't work with LineEdit
    By ia32 in forum Qt Tools
    Replies: 2
    Last Post: 5th May 2008, 22:44
  4. Replies: 4
    Last Post: 20th February 2006, 10:11
  5. subclassing or redrawing a lineEdit
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 7th February 2006, 19:26

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.