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. Paint shadow inside an QImage or QGraphicsEffect Shadow... html page doc
Forum Updated to NodeBB v4.3 + New Features

Paint shadow inside an QImage or QGraphicsEffect Shadow... html page doc

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicseffectqabstractscrollhtml
3 Posts 2 Posters 1.7k 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.
  • P Offline
    P Offline
    patrik08
    wrote on last edited by
    #1

    How can i make a shadow allround one page 4-6 pixel?
    QGraphicsEffect is only for widged..?

    /// Background image for 1 html page in subclass QAbstractScrollArea A4 or other
    static QImage onepageimage( const QRectF big , qreal substract ) {
      QImage qImage(big.size().width() ,big.size().height(),QImage::Format_RGB32);
      qImage.fill(Qt::blue);
      QPainter *p = new QPainter();
      p->begin(&qImage);
      p->setPen(QPen(Qt::black,5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); /// shadow
      p->setBrush(Qt::white);
      /// p->setPen(Qt::NoPen);
      p->drawRect(QRectF(0,0,big.size().width() - substract , big.size().height() - substract ));
      p->save();
      bool bEnd = p->end();
      if (bEnd) {
          return qImage;
        } else {
          return QImage();
        }
    }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @patrik08 said in Paint shadow inside an QImage or QGraphicsEffect Shadow... html page doc:

      QGraphicsEffect

      Is for all classes that have setGraphicsEffect
      You can cheat
      https://stackoverflow.com/questions/3903223/qt4-how-to-blur-qpixmap-image

      the posts at the end if for Qt5+

      1 Reply Last reply
      1
      • P Offline
        P Offline
        patrik08
        wrote on last edited by
        #3

        Tanks ....
        Compiler accept only this way ...... ;-)

        #ifdef QT_NO_GRAPHICSEFFECT
        QImage applyEffectToPics(QImage src, QGraphicsEffect *effect, int extent = 0)
        {
            if(src.isNull()) return QImage();   //No need to do anything else!
            if(!effect) return src;             //No need to do anything else!
            QGraphicsScene scene;
            QGraphicsPixmapItem item;
            item.setPixmap(QPixmap::fromImage(src));
            item.setGraphicsEffect(effect);
            scene.addItem(&item);
            QImage res(src.size()+QSize(extent*2, extent*2), QImage::Format_ARGB32);
            res.fill(Qt::transparent);
            QPainter ptr(&res);
            scene.render(&ptr, QRectF(), QRectF( -extent, -extent, src.width()+extent*2, src.height()+extent*2 ) );
            return res;
        }
        #endif
        
        1 Reply Last reply
        1

        • Login

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