Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. In Qt6.4.2 I want to make a imageButton

In Qt6.4.2 I want to make a imageButton

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 3 Posters 598 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.
  • R Offline
    R Offline
    rhaps20
    wrote on last edited by
    #1

    OS: debian11
    Target : android
    Qt version : 6.4.2

    I want create a image Button.

    QString testPath = ":/icons/play.png";
    
        playButton = new QPushButton;
        {
            QPixmap buttonImage;
            if (buttonImage.load(testPath)) {
                QIcon icon(buttonImage);
                playButton->setIcon(icon);
                playButton->setIconSize(QSize(50, 50));
            } else {
                label->setText("fail");
            }
        }
    

    always fail.

    my project path is "~/dev/qt/"
    project name is "android"
    and images are included in "icons" folder.

    I tried

    ":~/dev/qt/android/icons/play.png"
    ":/home/[account name]/dev/qt/android/icons/play.png"
    ":/icons/play.png"

    all is fail.

    Could you tell me How to fix my code?

    jsulmJ 1 Reply Last reply
    0
    • M Offline
      M Offline
      matzrm
      wrote on last edited by
      #2

      In my opinion trying to use Qt for android is only a waste of time, is full of bug.

      R 1 Reply Last reply
      0
      • M matzrm

        In my opinion trying to use Qt for android is only a waste of time, is full of bug.

        R Offline
        R Offline
        rhaps20
        wrote on last edited by
        #3

        @matzrm thanks for your opinion...

        1 Reply Last reply
        0
        • R rhaps20

          OS: debian11
          Target : android
          Qt version : 6.4.2

          I want create a image Button.

          QString testPath = ":/icons/play.png";
          
              playButton = new QPushButton;
              {
                  QPixmap buttonImage;
                  if (buttonImage.load(testPath)) {
                      QIcon icon(buttonImage);
                      playButton->setIcon(icon);
                      playButton->setIconSize(QSize(50, 50));
                  } else {
                      label->setText("fail");
                  }
              }
          

          always fail.

          my project path is "~/dev/qt/"
          project name is "android"
          and images are included in "icons" folder.

          I tried

          ":~/dev/qt/android/icons/play.png"
          ":/home/[account name]/dev/qt/android/icons/play.png"
          ":/icons/play.png"

          all is fail.

          Could you tell me How to fix my code?

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

          @rhaps20 said in In Qt6.4.2 I want to make a imageButton:

          and images are included in "icons" folder.

          Did you add these images to a resource file (https://doc.qt.io/qt-5/resources.html)?

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

          R 1 Reply Last reply
          1
          • jsulmJ jsulm

            @rhaps20 said in In Qt6.4.2 I want to make a imageButton:

            and images are included in "icons" folder.

            Did you add these images to a resource file (https://doc.qt.io/qt-5/resources.html)?

            R Offline
            R Offline
            rhaps20
            wrote on last edited by
            #5

            @jsulm Thanks!! I succeed!

            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