Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved how to create slot for dynamically allocated button?

    General and Desktop
    3
    4
    1361
    Loading More Posts
    • 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
      fatemehkarimi last edited by

      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 joeQ 2 Replies Last reply Reply Quote 0
      • K
        koahnig @fatemehkarimi last edited by

        @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 Reply Quote 2
        • joeQ
          joeQ @fatemehkarimi last edited by

          @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 Reply Quote 4
          • F
            fatemehkarimi @joeQ last edited by

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

            1 Reply Last reply Reply Quote 1
            • First post
              Last post