Index: libs/libmythtv/dsmccobjcarousel.cpp
===================================================================
--- libs/libmythtv/dsmccobjcarousel.cpp	(revision 18762)
+++ libs/libmythtv/dsmccobjcarousel.cpp	(working copy)
@@ -67,8 +67,7 @@
 
     if (m_blocks[ddb->block_number] == NULL)
     {   // We haven't seen this block before.
-        QByteArray *block = new QByteArray;
-        block->duplicate((char*) data, ddb->len);
+        QByteArray *block = new QByteArray((const char*) data, ddb->len);
         // Add this to our set of blocks.
         m_blocks[ddb->block_number] = block;
         m_receivedData += ddb->len;
Index: libs/libmythtv/dsmcccache.h
===================================================================
--- libs/libmythtv/dsmcccache.h	(revision 18762)
+++ libs/libmythtv/dsmcccache.h	(working copy)
@@ -18,6 +18,7 @@
 class DSMCCCacheKey: public QByteArray
 {
   public:
+    DSMCCCacheKey(const char *data, uint sz) : QByteArray(data, (int) sz) {}
     DSMCCCacheKey() {}
     QString toString(void) const;
     // Operator used in < for DSMCCCacheReference
Index: libs/libmythtv/dsmcccache.cpp
===================================================================
--- libs/libmythtv/dsmcccache.cpp	(revision 18762)
+++ libs/libmythtv/dsmcccache.cpp	(working copy)
@@ -199,9 +199,7 @@
 // Add a file to the directory.
 void DSMCCCache::AddFileInfo(DSMCCCacheDir *pDir, const BiopBinding *pBB)
 {
-    QString name;
-    name.setAscii(pBB->m_name.m_comps[0].m_id
-                  /*, pBB->m_name.m_comps[0].m_id_len*/);
+    QString name = QString::fromAscii(pBB->m_name.m_comps[0].m_id);
 
     const DSMCCCacheReference *entry =
         pBB->m_ior.m_profile_body->GetReference();
@@ -217,9 +215,7 @@
 void DSMCCCache::AddDirInfo(DSMCCCacheDir *pDir, const BiopBinding *pBB)
 {
     // Is it already there?
-    QString name;
-    name.setAscii(pBB->m_name.m_comps[0].m_id
-                  /*, pBB->m_name.m_comps[0].m_id_len*/);
+    QString name =  QString::fromAscii(pBB->m_name.m_comps[0].m_id);
     const DSMCCCacheReference *entry =
         pBB->m_ior.m_profile_body->GetReference();
 
Index: libs/libmythtv/mhi.h
===================================================================
--- libs/libmythtv/mhi.h	(revision 18762)
+++ libs/libmythtv/mhi.h	(working copy)
@@ -18,7 +18,10 @@
 #include <QString>
 #include <QWaitCondition>
 #include <QImage>
+
+#ifdef QT3_SUPPORT
 #include <q3pointarray.h>
+#endif
 
 // MythTV headers
 #include "../libmythfreemheg/freemheg.h"
@@ -288,7 +291,11 @@
     virtual void DrawOval(int x, int y, int width, int height);
     virtual void DrawArcSector(int x, int y, int width, int height,
                                int start, int arc, bool isSector);
+#ifdef QT3_SUPPORT
     virtual void DrawPoly(bool isFilled, const Q3PointArray &points);
+#else
+    virtual void DrawPoly(bool isFilled, const QPolygon &points);
+#endif
 
   protected:
     void DrawRect(int x, int y, int width, int height, MHRgba colour);
Index: libs/libmythtv/dsmccbiop.cpp
===================================================================
--- libs/libmythtv/dsmccbiop.cpp	(revision 18762)
+++ libs/libmythtv/dsmccbiop.cpp	(working copy)
@@ -173,7 +173,7 @@
                        (buf[off + 2] << 8)  | (buf[off + 3]));
     off += 4;
     uint nObjLen = buf[off++];
-    m_objkey.duplicate((const char*)buf + off, nObjLen);
+    m_objkey = DSMCCCacheKey((const char*)buf + off, nObjLen);
     off += nObjLen;
     m_objkind_len = ((buf[off + 0] << 24) | (buf[off + 1] << 16) |
                      (buf[off + 2] << 8)  | (buf[off + 3]));
@@ -277,8 +277,7 @@
     DSMCCCacheReference ref(cachep->CarouselId(), cachep->ModuleId(),
                             cachep->StreamId(), m_objkey);
 
-    QByteArray filedata;
-    filedata.duplicate((const char *)data+(*curp), content_len);
+    QByteArray filedata = QByteArray((const char *)(data+(*curp)), content_len);
     filecache->CacheFileData(ref, filedata);
 
     (*curp) += content_len;
@@ -416,7 +415,7 @@
     version_major = data[off++];
     version_minor = data[off++];
     uint objKeyLen = data[off++]; /* <= 4 */
-    m_Reference.m_Key.duplicate((char*)data + off, objKeyLen);
+    m_Reference.m_Key = DSMCCCacheKey((const char*)data + off, objKeyLen);
     off += objKeyLen;
     return off;
 }
Index: libs/libmythtv/mhi.cpp
===================================================================
--- libs/libmythtv/mhi.cpp	(revision 18762)
+++ libs/libmythtv/mhi.cpp	(working copy)
@@ -1,9 +1,12 @@
 #include <unistd.h>
 
+#include <QPainter>
 #include <QRegion>
 #include <qbitarray.h>
 
-#include <Q3MemArray>
+#ifdef QT3_SUPPORT
+#include <q3memarray.h>
+#endif
 
 #include "mhi.h"
 #include "osd.h"
@@ -847,13 +850,13 @@
                 GetHeight() / MHIContext::StdDisplayHeight,
                 Qt::IgnoreAspectRatio,
                 Qt::SmoothTransformation);
-        AddToDisplay(q_scaled.convertDepth(32),
+        AddToDisplay(q_scaled.convertToFormat(QImage::Format_RGB32),
                      x * GetWidth() / MHIContext::StdDisplayWidth,
                      y * GetHeight() / MHIContext::StdDisplayHeight);
     }
     else if (!displayRect.isEmpty())
     { // We must clip the image.
-        QImage clipped = qImage.convertDepth(32)
+        QImage clipped = qImage.convertToFormat(QImage::Format_RGB32)
             .copy(displayRect.x() - x, displayRect.y() - y,
                   displayRect.width(), displayRect.height());
         QImage q_scaled =
@@ -876,7 +879,7 @@
 // the screen that is not covered with other visibles.
 void MHIContext::DrawBackground(const QRegion &reg)
 {
-    if (reg.isNull() || reg.isEmpty())
+    if (reg.isEmpty())
         return;
 
     QRect bounds = reg.boundingRect();
@@ -1313,8 +1316,15 @@
 void MHIDLA::DrawOval(int x, int y, int width, int height)
 {
     // Simple but inefficient way of drawing a ellipse.
+
+#ifndef QT3_SUPPORT
+    QPolygon ellipse;
+#   warning MHEG not supported with Qt4
+#else
     Q3PointArray ellipse;
     ellipse.makeEllipse(x, y, width, height);
+#endif
+
     DrawPoly(true, ellipse);
 }
 
@@ -1322,11 +1332,18 @@
 void MHIDLA::DrawArcSector(int x, int y, int width, int height,
                            int start, int arc, bool isSector)
 {
-    Q3PointArray points;
     // MHEG and Qt both measure arcs as angles anticlockwise from
     // the 3 o'clock position but MHEG uses 64ths of a degree
     // whereas Qt uses 16ths.
+
+#ifndef QT3_SUPPORT
+    QPolygon points;
+#   warning MHEG not supported with Qt4
+#else
+    Q3PointArray points;
     points.makeArc(x, y, width, height, start/4, arc/4);
+#endif
+
     if (isSector)
     {
         // Have to add the centre as a point and fill the figure.
@@ -1344,12 +1361,19 @@
 // a result of rounding when drawing ellipses.
 typedef struct { int yBottom, yTop, xBottom; float slope; } lineSeg;
 
+#ifndef QT3_SUPPORT
+void MHIDLA::DrawPoly(bool isFilled, const QPolygon &points)
+#else
 void MHIDLA::DrawPoly(bool isFilled, const Q3PointArray &points)
+#endif
 {
     int nPoints = points.size();
     if (nPoints < 2)
         return;
 
+#ifndef QT3_SUPPORT
+#warning MHEG not supported with Qt4
+#else
     if (isFilled)
     {
         Q3MemArray <lineSeg> lineArray(nPoints);
@@ -1432,6 +1456,7 @@
             DrawLine(points[i].x(), points[i].y(), points[i-1].x(), points[i-1].y());
         }
     }
+#endif // QT3_SUPPORT
 }
 
 
@@ -1444,13 +1469,17 @@
         // Construct an image the size of the bounding box and tile the
         // bitmap over this.
         QImage tiledImage = QImage(rect.width(), rect.height(),
-                                   m_image.depth());
+                                   m_image.format());
 
         for (int i = 0; i < rect.width(); i += m_image.width())
         {
             for (int j = 0; j < rect.height(); j += m_image.height())
             {
-                bitBlt( &tiledImage, i, j, &m_image, 0, 0, -1, -1, (Qt::ImageConversionFlags)0);
+                if (tiledImage.isNull() || m_image.isNull())
+                    continue;
+                QPainter p(&tiledImage);
+                p.drawImage(QPoint(i,j), m_image, QRect(0,0,-1,-1),
+                            (Qt::ImageConversionFlags)0);
             }
         }
         m_parent->DrawImage(rect.x(), rect.y(), rect, tiledImage);
@@ -1464,16 +1493,26 @@
 // Create a bitmap from PNG.
 void MHIBitmap::CreateFromPNG(const unsigned char *data, int length)
 {
-    m_image.reset();
+    m_image = QImage();
 
     if (!m_image.loadFromData(data, length, "PNG"))
     {
-        m_image.reset();
+        m_image = QImage();
         return;
     }
 
     // Assume that if it has an alpha buffer then it's partly transparent.
-    m_opaque = ! m_image.hasAlphaBuffer();
+    bool can_be_transparent =
+        QImage::Format_ARGB32                 == m_image.format() ||
+        QImage::Format_ARGB32_Premultiplied   == m_image.format();
+    #if QT_VERSION >= 0x040400 
+    can_be_transparent |=
+        QImage::Format_ARGB8565_Premultiplied == m_image.format() ||
+        QImage::Format_ARGB8555_Premultiplied == m_image.format() ||
+        QImage::Format_ARGB6666_Premultiplied == m_image.format() ||
+        QImage::Format_ARGB4444_Premultiplied == m_image.format();
+    #endif
+    m_opaque = !can_be_transparent;
 }
 
 // Convert an MPEG I-frame into a bitmap.  This is used as the way of
@@ -1487,7 +1526,7 @@
     AVFrame *picture = NULL;
     uint8_t *buff = NULL, *buffPtr;
     int gotPicture = 0, len;
-    m_image.reset();
+    m_image = QImage();
 
     // Find the mpeg2 video decoder.
     AVCodec *codec = avcodec_find_decoder(CODEC_ID_MPEG2VIDEO);
@@ -1579,7 +1618,7 @@
 
     if (newWidth <= 0 || newHeight <= 0)
     { // This would be a bit silly but handle it anyway.
-        m_image.reset();
+        m_image = QImage();
         return;
     }
 
Index: libs/libmythfreemheg/freemheg.h
===================================================================
--- libs/libmythfreemheg/freemheg.h	(revision 18762)
+++ libs/libmythfreemheg/freemheg.h	(working copy)
@@ -23,9 +23,11 @@
 #define FREEMHEG_H
 
 #include <qregion.h>
-#include <Q3PointArray>
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef QT3_SUPPORT
+#include <q3pointarray.h>
+#endif
 
 class MHDLADisplay;
 class MHTextDisplay;
@@ -159,7 +161,13 @@
     virtual void DrawBorderedRectangle(int x, int y, int width, int height) = 0;
     virtual void DrawOval(int x, int y, int width, int height) = 0;
     virtual void DrawArcSector(int x, int y, int width, int height, int start, int arc, bool isSector) = 0;
+
+#ifdef QT3_SUPPORT
     virtual void DrawPoly(bool isFilled, const Q3PointArray &points) = 0;
+#else
+    virtual void DrawPoly(bool isFilled, const QPolygon &points) = 0;
+#endif
+
 };
 
 class MHTextDisplay {
