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. QCursor: Cannot create bitmap cursor; invalid bitmap(s)

QCursor: Cannot create bitmap cursor; invalid bitmap(s)

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 3 Posters 3.6k 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.
  • D Offline
    D Offline
    Delavega77
    wrote on 18 Dec 2019, 08:05 last edited by
    #1

    I'm trying to change the cursor Image but I got the following error:
    QCursor: Cannot create bitmap cursor; invalid bitmap(s)

    I tried both:
    QCursor(QBitmap("qrc:/cursorTarget.bmp"));
    QCursor(QPixmap("qrc:/cursorTarget.png"));
    Please help me
    Thanks

    J 1 Reply Last reply 18 Dec 2019, 08:28
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 18 Dec 2019, 08:28 last edited by
      #2

      Do the files actually exist? Please check with QFile::exists() before trying to create a cursor

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • D Delavega77
        18 Dec 2019, 08:05

        I'm trying to change the cursor Image but I got the following error:
        QCursor: Cannot create bitmap cursor; invalid bitmap(s)

        I tried both:
        QCursor(QBitmap("qrc:/cursorTarget.bmp"));
        QCursor(QPixmap("qrc:/cursorTarget.png"));
        Please help me
        Thanks

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 18 Dec 2019, 08:28 last edited by
        #3

        @Delavega77 said in QCursor: Cannot create bitmap cursor; invalid bitmap(s):

        qrc:/cursorTarget.bmp

        Does it exist and contains valid bitmap?
        What does

        qDebug() << QBitmap("qrc:/cursorTarget.bmp").isNul();
        

        return?

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

        D 1 Reply Last reply 20 Dec 2019, 06:13
        2
        • J jsulm
          18 Dec 2019, 08:28

          @Delavega77 said in QCursor: Cannot create bitmap cursor; invalid bitmap(s):

          qrc:/cursorTarget.bmp

          Does it exist and contains valid bitmap?
          What does

          qDebug() << QBitmap("qrc:/cursorTarget.bmp").isNul();
          

          return?

          D Offline
          D Offline
          Delavega77
          wrote on 20 Dec 2019, 06:13 last edited by
          #4

          @jsulm Thank your for your reply.
          Yes the file exists .

          J 1 Reply Last reply 20 Dec 2019, 06:16
          0
          • D Delavega77
            20 Dec 2019, 06:13

            @jsulm Thank your for your reply.
            Yes the file exists .

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 20 Dec 2019, 06:16 last edited by
            #5

            @Delavega77 So, isNull() returns false?

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

            D 1 Reply Last reply 20 Dec 2019, 06:34
            1
            • J jsulm
              20 Dec 2019, 06:16

              @Delavega77 So, isNull() returns false?

              D Offline
              D Offline
              Delavega77
              wrote on 20 Dec 2019, 06:34 last edited by
              #6

              @jsulm file.exists( ) return true;
              qDebug() << QBitmap("qrc:/cursorTarget.bmp").isNull(); return false;
              but when i try to create the cursor i get that error

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 20 Dec 2019, 06:50 last edited by
                #7

                Can you upload the bitmap so we can try out by ourself?

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                D 1 Reply Last reply 20 Dec 2019, 06:54
                1
                • C Christian Ehrlicher
                  20 Dec 2019, 06:50

                  Can you upload the bitmap so we can try out by ourself?

                  D Offline
                  D Offline
                  Delavega77
                  wrote on 20 Dec 2019, 06:54 last edited by
                  #8

                  @Christian-Ehrlicher it was my fault; now i dont' get any error when creates the cursor but when i set the cursor to a quickItem in c++ i doesn't have any effect.
                  QCursor jackpotCursor= QCursor(QPixmap(":/cursorTarget.png"));
                  window->setCursor(jackpotCursor);

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 20 Dec 2019, 07:12 last edited by
                    #9

                    Can you try out with a QWidget first, if it works try to create a minimal testcase for a QQuickWhatever

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    D 1 Reply Last reply 20 Dec 2019, 07:33
                    1
                    • C Christian Ehrlicher
                      20 Dec 2019, 07:12

                      Can you try out with a QWidget first, if it works try to create a minimal testcase for a QQuickWhatever

                      D Offline
                      D Offline
                      Delavega77
                      wrote on 20 Dec 2019, 07:33 last edited by
                      #10

                      @Christian-Ehrlicher I tried with a QWidget and it works fine...

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on 20 Dec 2019, 08:36 last edited by
                        #11

                        Then you should create a small testcase and create a bug report (and post the link here)

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        0

                        1/11

                        18 Dec 2019, 08:05

                        • Login

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