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 last edited by adityatrikha08
    #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
    • Pradeep KumarP Offline
      Pradeep KumarP Offline
      Pradeep Kumar
      wrote on last edited by Pradeep Kumar
      #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
      6
      • Pradeep KumarP Pradeep Kumar

        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 last edited by
        #3

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

        1 Reply Last reply
        1
        • Pradeep KumarP Offline
          Pradeep KumarP Offline
          Pradeep Kumar
          wrote on 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

          • Login

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