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. Waiting for User to Click Button, then continue code
QtWS25 Last Chance

Waiting for User to Click Button, then continue code

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.4k Views
  • 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.
  • K Offline
    K Offline
    kr2i
    wrote on last edited by
    #1

    So basically, I have a function

    @

    void mainInterface::simulation()
    {

    //Initialize QTextCursor
    //Needed in every function that modifies the console!
    QTextEdit *editor = new QTextEdit();
    editor = ui->console;
    QTextCursor cursor(editor->textCursor());
    cursor.insertText(tr("\nDone!\n"));
    cursor.insertText(tr("Ready to begin simulation?"));
    
    ui->interactionButton2->setText("Begin");
    ui->interactionButton3->setText("Back to Main Menu");
    qApp->processEvents(); //Doesnt work.... I tried verifying by adding a qwait after it, and it just didnt update the GUI
    
    //Start printing a whole bunch more stuff to console.
    

    }
    @

    And I need it so that when interactionButton2 is pressed, it continues the program.

    I have it connected to a slot here
    @
    connect(ui->interactionButton2, SIGNAL(pressed()), this, SLOT(button2Slot(int)));
    @

    Here is my slot definition
    @
    void mainInterface::button2Slot(int casenumber2)
    {
    switch(casenumber2)
    {
    case 0:{
    this->button2Response = true;
    }
    }
    }
    @

    If you need more details I'd be glad to give them, I've been frustrated by this program for so long I'll do anything haha. This may be something very simple to some of you vets, but Im just used to C#.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stevenceuppens
      wrote on last edited by
      #2

      Hi,

      Your connection is wrong,

      A connection exists of:
      connect(member, signal, member slot)

      A Signal may have more parameters than a slot, but not reverse..

      you did:
      @
      connect(ui->interactionButton2, SIGNAL(pressed()), this, SLOT(button2Slot(int)));
      @

      and you should remove the "int" argument of your slot, as it is not delivered by the signal.

      some info:

      http://qt-project.org/wiki/How_to_Use_QPushButton
      http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html

      Steven CEUPPENS
      Developer / Architect
      Mobile: +32 479 65 93 10

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kr2i
        wrote on last edited by
        #3

        Thanks for the reply Steven, I have been getting errors pertaining to my connections, but for the most part they have been functional.

        When I tried your suggestion, it spit out in the Application Output

        @
        QObject::connect: No such slot mainInterface::button2Slot() in ..\DETSv0-1\maininterface.cpp:52
        QObject::connect: (sender name: 'interactionButton2')
        QObject::connect: (receiver name: 'mainInterface')
        @

        But otherwise with how I had it I get,
        @
        QObject::connect: Incompatible sender/receiver arguments
        QPushButton::pressed() --> mainInterface::button3Slot(int)
        @

        Do you mean for me to absolutely not pass any variables to the slot at all? Remove int from the header and everything?

        Besides that point, how about my most pertinent problem?
        How to get the program to wait for the begin button to be pressed.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kr2i
          wrote on last edited by
          #4

          Update:

          bq. Do you mean for me to absolutely not pass any variables to the slot at all? Remove int from the header and everything?

          This does remove all my signal/slot errors, thanks!

          My main question still stands though.

          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