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. QPushbutton using method?
Forum Updated to NodeBB v4.3 + New Features

QPushbutton using method?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 341 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.
  • E Offline
    E Offline
    Endorfin35
    wrote on last edited by
    #1

    Hello to everyone,

    I'm newbie to Qt and trying to learn. For example, I want to change the content of a QLabel with a QPushbutton. To do this, I write a private slot function and it gets what I want, but I doubted if this is the right (simplest) way. Is there an alternative way to do this job without writing slots?

    Thanks for attention...

    PS: I'm coding in C++....

    JonBJ jsulmJ 2 Replies Last reply
    0
    • E Endorfin35

      Hello to everyone,

      I'm newbie to Qt and trying to learn. For example, I want to change the content of a QLabel with a QPushbutton. To do this, I write a private slot function and it gets what I want, but I doubted if this is the right (simplest) way. Is there an alternative way to do this job without writing slots?

      Thanks for attention...

      PS: I'm coding in C++....

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Endorfin35
      No alternative, you absolutely should put a slot on the button click and set the label text there as you describe, this is the correct paradigm with Qt.

      1 Reply Last reply
      2
      • E Endorfin35

        Hello to everyone,

        I'm newbie to Qt and trying to learn. For example, I want to change the content of a QLabel with a QPushbutton. To do this, I write a private slot function and it gets what I want, but I doubted if this is the right (simplest) way. Is there an alternative way to do this job without writing slots?

        Thanks for attention...

        PS: I'm coding in C++....

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Endorfin35 said in QPushbutton using method?:

        Is there an alternative way to do this job without writing slots?

        No, if you want to do something when a button is clicked you have to use signals/slots. Also, signals/slots is one of the most basic things in Qt.
        Actually there is one simplification you can do: instead of implementing a slot method use a C++ lambda function.

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

        1 Reply Last reply
        1
        • E Offline
          E Offline
          Endorfin35
          wrote on last edited by
          #4

          @JonB said in QPushbutton using method?:

          @Endorfin35
          No alternative, you absolutely should put a slot on the button click and set the label text there as you describe, this is the correct paradigm with Qt.

          This is my answer. Thanks guys.

          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