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 use IMAGE AS BUTTON?
Forum Updated to NodeBB v4.3 + New Features

How to use IMAGE AS BUTTON?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 4.2k 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.
  • A Offline
    A Offline
    adityatrikha08
    wrote on 10 Jan 2018, 09:37 last edited by adityatrikha08 1 Oct 2018, 09:40
    #1

    I want to insert an IMAGE, and use that particular IMAGE AS BUTTON.

    Using only the code option and not use the DESIGN PART.

    eg: The play and pause button which appear as inverted triangle and a square respectively , in a video file etc.

    Could I get help with same.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Pradeep Kumar
      wrote on 10 Jan 2018, 10:01 last edited by Pradeep Kumar 1 Oct 2018, 12:13
      #2

      Hi,

      You can use QPushButton, and add the image we have setIcon() method

      QPushbutton *button = new QPushbutton;
      button->setIcon(QIcon("<imagePath>"));

      Add images in the resource file, as it will relative path, dont provide absolute path.
      Based on the condition, change the image in Button, for play and pause.

      Thanks,

      Pradeep Kumar
      Qt,QML Developer

      A 1 Reply Last reply 15 Jan 2018, 06:31
      6
      • P Pradeep Kumar
        10 Jan 2018, 10:01

        Hi,

        You can use QPushButton, and add the image we have setIcon() method

        QPushbutton *button = new QPushbutton;
        button->setIcon(QIcon("<imagePath>"));

        Add images in the resource file, as it will relative path, dont provide absolute path.
        Based on the condition, change the image in Button, for play and pause.

        Thanks,

        A Offline
        A Offline
        adityatrikha08
        wrote on 15 Jan 2018, 06:31 last edited by
        #3

        @Pradeep-Kumar Thanks Sir, Now its working,
        I was giving absolute path.

        1 Reply Last reply
        1
        • P Offline
          P Offline
          Pradeep Kumar
          wrote on 15 Jan 2018, 09:53 last edited by Pradeep Kumar
          #4

          Hi @adityatrikha08 ,

          Glad u got the solution, happy coding.

          Thanks,

          Pradeep Kumar
          Qt,QML Developer

          1 Reply Last reply
          0

          4/4

          15 Jan 2018, 09:53

          • Login

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