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. how to create slot for dynamically allocated button?

how to create slot for dynamically allocated button?

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

    in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).

    Thank you very much

    K joeQJ 2 Replies Last reply
    0
    • F fatemehkarimi

      in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).

      Thank you very much

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @fatemehkarimi

      Note your post is in the forum lounge. Typically there are questions and discussions addressed which are not taken very serious. If you misplaced this thread, please let us know and a moderator can moved it for you.

      Typically you have a plain QPushButton or you have created your own inheritating from QPushButton. There you have already your slots implemented. When you dynamically create a new object of those push buttons, you simply have to connect as you do with any push button.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      2
      • F fatemehkarimi

        in my app, I should add Qpushbutton to my group box dynamically. now I want to set slot for these buttons. how can I do that??( when the button is clicked a new Qdialog must be shown).

        Thank you very much

        joeQJ Offline
        joeQJ Offline
        joeQ
        wrote on last edited by
        #3

        @fatemehkarimi Hi, friend, welcome. look here.

        You can watch QObject::connect

        /**....some code here...*/
        
        QPushButton* btn = new QPushButton(parent);
        connect(btn,&QPushButton::clicked,this,&Class::Function);
        
        /**....some code here...*/
        

        Just do it!

        F 1 Reply Last reply
        4
        • joeQJ joeQ

          @fatemehkarimi Hi, friend, welcome. look here.

          You can watch QObject::connect

          /**....some code here...*/
          
          QPushButton* btn = new QPushButton(parent);
          connect(btn,&QPushButton::clicked,this,&Class::Function);
          
          /**....some code here...*/
          
          F Offline
          F Offline
          fatemehkarimi
          wrote on last edited by
          #4

          @joeQ thank you very much!! it worked!!! :)))

          1 Reply Last reply
          1

          • Login

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