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. [Solved] Connect combobox using signals
Forum Updated to NodeBB v4.3 + New Features

[Solved] Connect combobox using signals

Scheduled Pinned Locked Moved General and Desktop
qcomboboxsignal
22 Posts 3 Posters 15.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.
  • RatzzR Ratzz

    @p3c0
    thank you.
    I used this
    combobox = new QComboBox(this);
    Is it the proper way to do it ?

    p3c0P Offline
    p3c0P Offline
    p3c0
    Moderators
    wrote on last edited by p3c0
    #13

    @Ratzz Correct. Now the rest should work. Just don't forget to change the slot's definition.

    157

    1 Reply Last reply
    0
    • RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #14

      @p3c0 Why to change the slot definition?

      --Alles ist gut.

      p3c0P 1 Reply Last reply
      0
      • RatzzR Ratzz

        @p3c0 Why to change the slot definition?

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #15

        @Ratzz Because in you have connected the signal activated to slot m_combobox which takes one argument.
        connect(combobox,SIGNAL (activated(int)),this,SLOT(m_combobox(int)));
        But there is no such slot defined with single argument and thus the connection will fail as it will not be able to find that slot. You have a slot m_combobox() which takes no arguments.

        157

        1 Reply Last reply
        0
        • RatzzR Offline
          RatzzR Offline
          Ratzz
          wrote on last edited by
          #16

          @p3c0
          i used setGeometry() to assign position

          •  pushbutton->setGeometry(QRect(QPoint(100, 200),QSize(90, 40)));
            

          How to do use move();?

          --Alles ist gut.

          p3c0P 1 Reply Last reply
          0
          • RatzzR Ratzz

            @p3c0
            i used setGeometry() to assign position

            •  pushbutton->setGeometry(QRect(QPoint(100, 200),QSize(90, 40)));
              

            How to do use move();?

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #17

            @Ratzz pushbutton->move(10,100). See http://doc.qt.io/qt-5/qwidget.html#pos-prop
            But as said earlier its best to use Layouts. See using Layouts for more details.

            157

            1 Reply Last reply
            1
            • RatzzR Offline
              RatzzR Offline
              Ratzz
              wrote on last edited by
              #18

              @p3c0 Can you give me rough sketch for my slot?

              --Alles ist gut.

              p3c0P 1 Reply Last reply
              0
              • RatzzR Ratzz

                @p3c0 Can you give me rough sketch for my slot?

                p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #19

                @Ratzz
                connect(combobox,SIGNAL (activated(int)),this,SLOT(m_combobox(int))); -> This is correct
                mainwindow.h

                private slots:
                    void m_combobox(int index);
                

                mainwindow.cpp

                void MainWindow::m_combobox(int index)
                {
                    label->setText("1");
                }
                

                157

                1 Reply Last reply
                1
                • RatzzR Offline
                  RatzzR Offline
                  Ratzz
                  wrote on last edited by
                  #20

                  @p3c0
                  Thank you.
                  I will try using Layouts.

                  --Alles ist gut.

                  p3c0P 1 Reply Last reply
                  0
                  • RatzzR Ratzz

                    @p3c0
                    Thank you.
                    I will try using Layouts.

                    p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #21

                    @Ratzz You're Welcome :)
                    Since you are new here few more forum related reminders:

                    • Always surround the code blocks with ``` (3 backticks) while posting so that it gets nicely formatted and thus more readable for others.
                    • Mark the post as solved by editing the post title and prepending [Solved]

                    Happy Qt Coding ...

                    157

                    1 Reply Last reply
                    1
                    • RatzzR Offline
                      RatzzR Offline
                      Ratzz
                      wrote on last edited by
                      #22

                      @p3c0
                      Sure :)

                      --Alles ist gut.

                      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