Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. SOLVED: Qt button assign command
Forum Updated to NodeBB v4.3 + New Features

SOLVED: Qt button assign command

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.5k 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.
  • 3 Offline
    3 Offline
    32sthide
    wrote on last edited by
    #1

    I'm using qt creator to create a gui for an vtk aplication.

    I've made a #define action and I want to assign that command to a QPushButton.

    How do I make the button reproduce my define if pressed?

    example. ui->pushButton->...

    Or if anyone knows a way to define an action in a different way than #define

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      you can create your signal/slot connection either with the designer directly or you have to use the connect() function QObject. For more information please check the manual of QObject

      1 Reply Last reply
      0
      • 3 Offline
        3 Offline
        32sthide
        wrote on last edited by
        #3

        having this
        @
        #define AlignXAxis();
        {
        int slice_number;
        int po = planeX->GetPlaneOrientation();
        if (po == 3)
        {
        planeX->SetPlaneOrientationToXAxes();
        slice_number = (xmax-xmin)/2;
        planeX->SetSliceIndex(slice_number);
        }
        else
        {
        slice_number = planeX->GetSliceIndex();
        }

            current_widget= planeX;
            ui->horizontalScrollBar->setValue(slice_number);
            ui->horizontalScrollBar->setMinimum(xmin);
            ui->horizontalScrollBar->setMaximum(xmax);
            AlignCamera();
        }
        

        @
        it would be something like this?
        @
        ui->pushButton->connect(SIGNAL(clicked()),SLOT(AlignXAxis()));
        @
        or this?
        @
        connect(pushButton,SIGNAL(clicked()),SLOT(AlignXAxis()));
        @
        i'm sorry, i'm real new at Qt.

        [Edit: Added @ tags for code formatting -- mlong]

        1 Reply Last reply
        0
        • M Offline
          M Offline
          messi
          wrote on last edited by
          #4

          Do you know this document, if not please read it first.
          It's fundamental for develoing with qt.

          http://qt-project.org/doc/qt-4.8/signalsandslots.html

          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