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. Difficulties in QCOMBOBOX
Forum Updated to NodeBB v4.3 + New Features

Difficulties in QCOMBOBOX

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 2.2k 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.
  • S Offline
    S Offline
    sush
    wrote on last edited by sush
    #3

    I am actually selecting a name of a doctor from a list of doctor names and according to the predefined data given by each doctor, certain fix values are displayed in the LCDnumber, the values for temperature and humidity are just for displaying purpose on the GUI.
    For example: There are 3 doctors namely Dr. ABC, Dr. PQR, Dr. XYZ, which are a part of list of combobox, now each doctor requires certain fix values of temperature and humidity on the GUI to be displayed as they select there own name on the combobox.

    Do not wait to innovate.

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

      Hi,

      Then use the parameter provided by currentIndexChanged (either the text or integer value) to retrieve the matching data from whatever source you may have.

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

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Then use the parameter provided by currentIndexChanged (either the text or integer value) to retrieve the matching data from whatever source you may have.

        S Offline
        S Offline
        sush
        wrote on last edited by
        #5

        @SGaist I guess according to what i have understood, as i select a name on the combobox, the index number or the name itself is passed to the slot but I'm naive as to how do i use this logic here .

        Do not wait to innovate.

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

          Which part ? The slot handling or the data handling ?

          For the slot just add the correct parameter to it:

          void MainWindow::temp1(int index)
          {
          }
          

          Or if using the QString parameter:

          void MainWindow::temp1(const QString &text)
          {
          }
          

          Don't forget to update your connect statement to match.

          If it's the data part that is problematic then you have to explain where it's located and how you access it.

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

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Which part ? The slot handling or the data handling ?

            For the slot just add the correct parameter to it:

            void MainWindow::temp1(int index)
            {
            }
            

            Or if using the QString parameter:

            void MainWindow::temp1(const QString &text)
            {
            }
            

            Don't forget to update your connect statement to match.

            If it's the data part that is problematic then you have to explain where it's located and how you access it.

            S Offline
            S Offline
            sush
            wrote on last edited by
            #7

            @SGaist by correct parameter you mean? I am actually having problem in slot handling only.

            Do not wait to innovate.

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

              There are two currentIndexChanged signals. The one you used that has an int parameter and the second one that has a QString parameter.

              Then depending on which one you need in order to do the stuff you want to do, you have to connect matching signals and slot. You have the choice between the two samples I wrote in my last post.

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

              S 1 Reply Last reply
              0
              • SGaistS SGaist

                There are two currentIndexChanged signals. The one you used that has an int parameter and the second one that has a QString parameter.

                Then depending on which one you need in order to do the stuff you want to do, you have to connect matching signals and slot. You have the choice between the two samples I wrote in my last post.

                S Offline
                S Offline
                sush
                wrote on last edited by
                #9

                @SGaist okay so, I did this
                connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(temp1(int index)));
                and
                void MainWindow::temp1(int index)
                {
                ui->temp->display(23);
                ui->humidity->display(40);
                }

                but still there are no changes in the GUI as I select the name from combobox.

                Do not wait to innovate.

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

                  Don't pass the parameter name, just the type i.e.

                  connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(temp1(int)));
                  and

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

                  S 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Don't pass the parameter name, just the type i.e.

                    connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(temp1(int)));
                    and
                    S Offline
                    S Offline
                    sush
                    wrote on last edited by
                    #11

                    @SGaist Thank you so much, it worked finally

                    Do not wait to innovate.

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

                      You^re welcome !

                      Since you have it working now, please mark the thread as solved using the "Tool Topic" button so that other forum users may know a solution has bben foud )

                      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
                      0

                      • Login

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