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. Trouble with slots and signals
Forum Updated to NodeBB v4.3 + New Features

Trouble with slots and signals

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 5.2k Views 1 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.
  • P Offline
    P Offline
    ProgrammerAtHeart3344
    wrote on last edited by
    #1

    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
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Try to use int instead of X in your last line

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • P Offline
        P Offline
        ProgrammerAtHeart3344
        wrote on last edited by
        #3

        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
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          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
          0
          • P Offline
            P Offline
            ProgrammerAtHeart3344
            wrote on last edited by
            #5

            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
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              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
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                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
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  [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
                  0

                  • Login

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