Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Trouble with slots and signals

    General and Desktop
    4
    8
    4636
    Loading More Posts
    • 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.
    • P
      ProgrammerAtHeart3344 last edited by

      Ok, i don't know how to explain it but i'm trying connect signals and slots but i'm having trouble such as this.

      @Object::connect: No such signal QComboBox::currentIndexChanged(X) in .\qttrail.cpp:33
      Object::connect: (receiver name: 'QtTrailClass')@

      here is the code:

      @#include "qttrail.h"
      #include <QtGui/QPushButton>
      #include <QtGui/QComboBox>
      #include <Windows.h>
      QtTrail::QtTrail(QWidget *parent, Qt::WFlags flags)
      : QMainWindow(parent, flags)
      {
      ui.setupUi(this);
      pBox = new PaintBox();
      pBox->show();

      QWidget* entity_tools = new QWidget(pBox);

      pBox->addItem(entity_tools, "Entities");

      QAction* push = new QAction("Add Light",pBox);

      QComboBox* com = new QComboBox(ui.page);

      this->nameList.push_back("Eggman");
      this->nameList.push_back("Snively");

      for(int X = 0; X < nameList.size()-1; ++X)
      {
      com->insertItems(X,nameList);
      }
      int X = com->currentIndex();

      if(X == 1)
      {
      MessageBoxA(NULL,"EE","",MB_OK);
      }
      QObject::connect(com,SIGNAL(currentIndexChanged(X)),this,SLOT(setCurrentIndex(X)));

      }@

      1 Reply Last reply Reply Quote 0
      • E
        Eddy last edited by

        Try to use int instead of X in your last line

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply Reply Quote 0
        • P
          ProgrammerAtHeart3344 last edited by

          nope still didn't this happens a lot to me for some reason I'm trying to make it so depending on the index pickec in the combo box it does different things. Maybe i don't fully understand slots and signals....hmm

          1 Reply Last reply Reply Quote 0
          • E
            Eddy last edited by

            did you make a setCurrentIndex slot for your QTrail class? setCurrentIndex is not a member function of QMainWindow which you are subclassing.

            did you get a message in application output saying the connect didn't work.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply Reply Quote 0
            • P
              ProgrammerAtHeart3344 last edited by

              yea, so if i want to set the current index of the combo box, i gotta do com->setCurrentIndex(int)? like i said Qt's slots and signals are a bit weird to get used to

              1 Reply Last reply Reply Quote 0
              • K
                koahnig last edited by

                You can write it also this way.

                @
                bool boo = connect(com,SIGNAL(currentIndexChanged(int)),this,SLOT(setCurrentIndex(int)));
                @

                Did you use int in signal and in slot? I would expect that the error message did change.

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply Reply Quote 0
                • E
                  Eddy last edited by

                  now you want to set the currentindex for the combobox?!
                  In your first post you wanted to use a slot for this which is your QtTrail class.

                  Normally you use a combobox to select items in it and based on that selection you can use the information to do something with it elsewhere.

                  can you explain in your own words what you want to accomplish?

                  This is good reading to learn more about signal slots :
                  http://developer.qt.nokia.com/doc/qt-4.7/signalsandslots.html

                  Qt Certified Specialist
                  www.edalsolutions.be

                  1 Reply Last reply Reply Quote 0
                  • G
                    giesbert last edited by

                    [quote author="ProgrammerAtHeart3344" date="1309702177"]nope still didn't this happens a lot to me for some reason I'm trying to make it so depending on the index pickec in the combo box it does different things. Maybe i don't fully understand slots and signals....hmm[/quote]

                    A signal can't be dependent on the parameter value, it's is translated to a function call. That's whxy it must be int not X.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post