Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Un problema con QTimer
Forum Updated to NodeBB v4.3 + New Features

Un problema con QTimer

Scheduled Pinned Locked Moved Unsolved Italian
3 Posts 3 Posters 738 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.
  • PollyP Offline
    PollyP Offline
    Polly
    wrote on last edited by
    #1

    Sono riuscito a creare un oggetto Qtimer seguendo la documentazione, ma quando ho cercato di connettere uno slot che mi serve mi dà questa notazione,

    QObject::connect: No such slot MainWindow::incremento(this->b) in ..\simulazionefresa\mainwindow.cpp:23
    QObject::connect:  (receiver name: 'MainWindow')
    

    Vorrei sapere dove sta l'errore ?
    VI copio il codice

    int b = 23;
    QTimer *m_timer = new QTimer(this);
        connect(m_timer,SIGNAL(timeout()),this,SLOT(incremento(int b)));
        m_timer->start(1000);
    
    void MainWindow::incremento(int a)
    {
       a += 1;
    }
    
    1 Reply Last reply
    0
    • mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #2

      Ciao, non puoi collegare un evento che vuole una funzione senza parametri con una che vuole un intero.

      Ciao ciao.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        ci sono 2 problemi:

        • non puoi passare un parametro fisso allo slot usando il vecchio connect (risolvilile passando al connect di Qt5)
        • b muore appena va fuori scope

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        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