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. Question about QCursor constructor
Forum Updated to NodeBB v4.3 + New Features

Question about QCursor constructor

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 576 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.
  • L Offline
    L Offline
    lniwn
    wrote on last edited by
    #1
    QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
        : d(0)
    {
        QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
        QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither);
        QBitmap bmm = pixmap.mask();
        if (!bmm.isNull()) {
            QBitmap nullBm;
            bm.setMask(nullBm);
        }
        else if (!pixmap.mask().isNull()) {
            QImage mimg = pixmap.mask().toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
            bmm = QBitmap::fromImage(mimg, Qt::ThresholdDither|Qt::AvoidDither);
        }
        else {
            bmm = QBitmap(bm.size());
            bmm.fill(Qt::color1);
        }
    
        d = QCursorData::setBitmap(bm, bmm, hotX, hotY, pixmap.devicePixelRatio());
        d->pixmap = pixmap;
    }
    

    source code is here

    Dose the conditional branch if and else if test same case??

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      yes. The are same. What is the issue you are facing ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      L 1 Reply Last reply
      0
      • dheerendraD dheerendra

        yes. The are same. What is the issue you are facing ?

        L Offline
        L Offline
        lniwn
        wrote on last edited by
        #3

        @dheerendra

        Thanks for your reply.
        Just questioning the logic of this code, and curious why it has not been fixed.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @lniwn said in Question about QCursor constructor:

          if (!bmm.isNull()) {

          I would guess the '!' is wrong here. Please create a bug report and post the bug number here. Thx.

          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

          • Login

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