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. create control event function
Forum Updated to NodeBB v4.3 + New Features

create control event function

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 766 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.
  • H Offline
    H Offline
    hawiwo
    wrote on 14 Jun 2018, 06:21 last edited by
    #1

    Hi,
    as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
    i am using Visual Studio 2016 and the Qt designer 5.11.0.
    a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
    thats what i have expexted.

    But there is no "goto slot" action in the controls context menu!

    How do i do that!

    J V 2 Replies Last reply 14 Jun 2018, 06:37
    0
    • H hawiwo
      14 Jun 2018, 06:21

      Hi,
      as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
      i am using Visual Studio 2016 and the Qt designer 5.11.0.
      a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
      thats what i have expexted.

      But there is no "goto slot" action in the controls context menu!

      How do i do that!

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 14 Jun 2018, 06:37 last edited by
      #2

      @hawiwo I guess you mean OnClick slot, not event?
      This is simple: right click on the push button, then you will see "Go to slot..." in the context menu.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • H hawiwo
        14 Jun 2018, 06:21

        Hi,
        as qt (designer) beginner i wonder how to create e.g. a pushButtons OnClick Event and code it (c++)
        i am using Visual Studio 2016 and the Qt designer 5.11.0.
        a youtube tutorial describes: right click on the control -> "goto slot" ->.... ends with a ...::on_pushButton_clicked() function.
        thats what i have expexted.

        But there is no "goto slot" action in the controls context menu!

        How do i do that!

        V Offline
        V Offline
        VRonin
        wrote on 14 Jun 2018, 07:27 last edited by VRonin
        #3

        It's is usually safer to do the connection manually in the constructor, connecting by name backfires too often.

        Under private slots: add void onButtonClicked(); (you can give it whatever name you like) then in the constructor, after setupUi() add connect(ui->pushButton,&QPushButton::clicked,this,&MyClass::onButtonClicked); (of course MyClass is the name of the class you are editing


        P.S.
        @hawiwo said in create control event function:

        i am using Visual Studio 2016

        Doubt

        "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
        3
        • H Offline
          H Offline
          hawiwo
          wrote on 14 Jun 2018, 08:52 last edited by
          #4

          ok works.
          Thanks!

          1 Reply Last reply
          0

          1/4

          14 Jun 2018, 06:21

          • Login

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