Results 1 to 6 of 6

Thread: qtScrollDial and QLCDNumber communication

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default qtScrollDial and QLCDNumber communication

    Let's consider this case\

    I have three QtScrollDials, each representing one digit of a float number. the last one is for after-the-point digit.
    I also have one QLCDNumber, what I am preferring to do is
    when the operator sets each of these three QtScrollDials, the related digit in the QLCDNumber is changed accordingly.

  2. #2
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qtScrollDial and QLCDNumber communication

    I'm sure you can figure out how to update a number when its hundreds, tens, ones, and tenths change, so...

    (I assume you're referring to the QtScrollDial demo widget)

    Attach a slot to the dial's signal used to indicate a value change ( valueChanged(int) ), in that slot, get the current value of the QLCDNumber widget, update it appropriately, and then set the value back into the QLCDNumber widget.

  3. #3
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: qtScrollDial and QLCDNumber communication

    I have a problem here, I have 3 QtScrollDials inside X class. I edited the updateLabel slot of QtScrollDials class so when it updates the label it also sends a signal to X class, so that I can get its value and set my QLCDNumber accordingly.
    Qt Code:
    1. void QtScrollDial::updateLabelValue()
    2. {
    3. m_label->setText(QString::number(value()));
    4. emit updateDisplaySignal_valueChangedDahgan(value());
    5. }
    To copy to clipboard, switch view to plain text mode 

    The problem I have is that I have 3 dials, not one, for each of these dials I need to emit 3 different signals so that I can understand which dial sent the signal.
    do have any idea how I can do that?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtScrollDial and QLCDNumber communication

    Read aout QObject::sender

  5. #5
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: qtScrollDial and QLCDNumber communication

    Quote Originally Posted by Lesiok View Post
    Read aout QObject::sender
    this is QtScrollDial SLOT:
    Qt Code:
    1. void QtScrollDial::updateLabelValue()
    2. {
    3. m_label->setText(QString::number(value()));
    4.  
    5. emit updateDisplaySignal_valueChanged(value());
    6. }
    To copy to clipboard, switch view to plain text mode 

    Inside X class
    let's connect all 3 QtScrollDials to the above signal:
    Qt Code:
    1. connect(myScrollDial, SIGNAL(updateDisplaySignal_valueChanged(int)), this, SLOT(scrollPopUp_valueChanged(int)));
    2. connect(myScrollDial_2, SIGNAL(updateDisplaySignal_valueChanged(int)), this, SLOT(scrollPopUp_valueChanged(int)));
    3. connect(myScrollDial_3, SIGNAL(updateDisplaySignal_valueChanged(int)), this, SLOT(scrollPopUp_valueChanged(int)));
    To copy to clipboard, switch view to plain text mode 

    inside the Slot I write this
    Qt Code:
    1. QObject *sender = QObject::sender();
    2. qDebug() << sender->objectName();
    To copy to clipboard, switch view to plain text mode 


    Everytime I run the program, sender gives me different addresses, and object name prints null.
    Last edited by saman_artorious; 27th February 2013 at 08:01.

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtScrollDial and QLCDNumber communication

    You don't need sender name. Just compare sender address to myScrollDial, myScrollDial_2 and myScrollDial_3 to detect which digit You must change.

Similar Threads

  1. Modelling a QLCDNumber in QML
    By lixo1 in forum Qt Quick
    Replies: 1
    Last Post: 24th August 2011, 14:19
  2. QLCDNumber problem
    By ale301168 in forum Newbie
    Replies: 1
    Last Post: 11th November 2009, 21:16
  3. QLCDNumber display
    By jhearon in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2008, 23:53
  4. QLCDNumber justify
    By davisjamesf in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 10:02
  5. QLabel and QLCDNumber
    By mickey in forum Newbie
    Replies: 5
    Last Post: 17th March 2006, 08:12

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.