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 give smooth transmision to avatar image

how give smooth transmision to avatar image

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 625 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.
  • B Offline
    B Offline
    Bharth
    wrote on last edited by Bharth
    #1

    hi,,,
    this is thecode i added
    ...................................

    QPixmap pix;
    pix.load("C:/Users/inno/Desktop/smile.jpg");
    pix.scaled(width(), height(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
    ui->pushButton->setIcon(QIcon(pix));

    ui->pushButton->setFixedHeight(90);
    ui->pushButton->setFixedWidth(90);
    

    QRect rect(0,0,90,90);
    QRegion region(rect, QRegion::Ellipse);
    ui->pushButton->setMask(region);

    please help me....

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      its unclear what you try
      pix.scaled(width(), height(), << what are those sizes , its not push button.

      so you try to take image and clip it to round avatar image , much like here at Qt forum ?

      Like here
      https://stackoverflow.com/questions/48474941/circle-user-avatar-issue

      1 Reply Last reply
      4
      • J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by J.Hilk
        #3

        if you actually wan‘t a fadeIn/fadeOut transition of 2 pixmaps, i believe you can do that via QProppertyAnimations that targets the opacity as Property


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2
        • B Offline
          B Offline
          Bharth
          wrote on last edited by Bharth
          #4

          thanks for your reply problem is sloved

          QPixmap pix;
          pix.loadFromData(image_data);
          int size = qMax(pix.width(), pix.height());
          QPixmap rounded = QPixmap(size, size);
          rounded.fill(Qt::transparent);
          QPainterPath path;
          path.addEllipse(rounded.rect());
          QPainter painter(&rounded);
          painter.setClipPath(path);
          painter.fillRect(rounded.rect(), Qt::black);
          int x = qAbs(pix.width() - size) / 2;
          int y = qAbs(pix.height() - size) / 2;
          painter.drawPixmap(x, y, pix.width(), pix.height(), pix);
          ui->pushButton_4->setIcon(QIcon(rounded));

          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