Results 1 to 5 of 5

Thread: Value from combo box to LCD

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Value from combo box to LCD

    I think you are missing "self" prefix when creating widgets. They don't land in the scope of your object.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Value from combo box to LCD

    Quote Originally Posted by wysota View Post
    I think you are missing "self" prefix when creating widgets. They don't land in the scope of your object.
    Thanks for your reply, but I do not understand it.

    The plotting demo, from which I based mine, does not use self when creating widgets, and runs correctly.
    The only thing that does not work, is my attempt to transfer a value from a combo box to an LCD.

    I do not understand "land in the scope of your object". Could you explain, please?

    Thanks,
    Don

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Value from combo box to LCD

    In "changeValue" you refer to some object "self.lcdVolts" but where is that object? I don't see you assigning anything to "self.lcdVolts" anywhere. "self.lcdVolts" and "lcdVolts" are two totally different objects.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following user says thank you to wysota for this useful post:

    dayo30 (31st January 2013)

  5. #4
    Join Date
    Aug 2012
    Posts
    9
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Value from combo box to LCD

    Quote Originally Posted by wysota View Post
    In "changeValue" you refer to some object "self.lcdVolts" but where is that object? I don't see you assigning anything to "self.lcdVolts" anywhere. "self.lcdVolts" and "lcdVolts" are two totally different objects.
    Well, I added "self" to all places where it seemed appropriate. The program runs fine with, or without, "self", but the value is still not transferred to the LCD.

    I'm still missing something, but can't figure out what.
    Thanks for your patience,
    Don

    Qt Code:
    1. def createTopRightGroupBox(self):
    2. self.topRightGroupBox = QtGui.QGroupBox("Top Right")
    3.  
    4. self.labelVolts = QtGui.QLabel("Volts/Div")
    5. self.labelVolts.setAlignment(QtCore.Qt.AlignHCenter)
    6.  
    7. self.comboVolts = QtGui.QComboBox()
    8. volts = ['2.5', '5.0', '10.0', '20.0']
    9. self.comboVolts.addItems(volts)
    10.  
    11. self.lcdVolts = QtGui.QLCDNumber()
    12.  
    13. layout = QtGui.QVBoxLayout()
    14. layout.addWidget(self.labelVolts)
    15. layout.addWidget(self.comboVolts)
    16. layout.addWidget(self.lcdVolts)
    17. layout.addStretch(1)
    18. self.topRightGroupBox.setLayout(layout)
    19.  
    20. # process signal
    21. self.connect(self.comboVolts, QtCore.SIGNAL('valueChanged(double)'), self.changeValue)
    22.  
    23. def changeValue(self, event):
    24. volts = self.comboVolts.value()
    25. self.lcdVolts.display(volts)
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 4
    Last Post: 2nd January 2013, 13:37
  2. How to create Combo box using QML in Qt
    By Channareddy in forum Newbie
    Replies: 0
    Last Post: 4th July 2011, 05:47
  3. Set selected text in combo box
    By kode in forum Newbie
    Replies: 0
    Last Post: 27th December 2010, 11:06
  4. Combo with cascading list
    By navi1084 in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2010, 05:20
  5. DropDown combo box
    By Tavit in forum Qt Programming
    Replies: 3
    Last Post: 3rd May 2008, 08:40

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
  •  
Qt is a trademark of The Qt Company.