Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. online changeable Qlabel or qlineedit

online changeable Qlabel or qlineedit

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 639 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TahaLotfi
    wrote on last edited by
    #1

    how can i have a QLabel or Qlineedit that i can change its text online to new number.
    for example first value is "0" when i set the text to 432.1 (in Qlabel or Qline ) in gui the new number show in command line.
    thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      If it's a number input you should consider using QSpinBox or QDoubleSpinBox.

      As for your question, do you mean connecting your widget a slot that would do something like qDebug() << newValue ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      T 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        If it's a number input you should consider using QSpinBox or QDoubleSpinBox.

        As for your question, do you mean connecting your widget a slot that would do something like qDebug() << newValue ?

        T Offline
        T Offline
        TahaLotfi
        wrote on last edited by
        #3

        @SGaist
        thanks
        my inputs are number. but i want to use Qlabel or Qlineedit to get float number from user and user can change value online. when value change , show it by qDebug()...

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then QDoubleSpinBox is what you want.

          As for the rest, please read the Signals And Slots chapter of Qt's documentation.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            Hi
            And when you read about signals and slots so you know what's it about,
            you can use the help to get the connect statement as its a bit funky due as there are 2 versions. (overloads)

            https://doc.qt.io/qt-5/qdoublespinbox.html#valueChanged

            connect(ui->doubleSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
                [=](double d){
                   qDebug() << d;
               });
            

            This uses a lambda for the slot.

            it will print in the Application output.
            alt text

            1 Reply Last reply
            2
            • T Offline
              T Offline
              TahaLotfi
              wrote on last edited by
              #6

              hi thank's
              How can i use float Numbers?

              mrjjM 1 Reply Last reply
              0
              • T TahaLotfi

                hi thank's
                How can i use float Numbers?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @TahaLotfi
                Hi
                it already uses doubles.
                so that should also work for float type.

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved