Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Polish
  4. QPixmap - ładowanie ścieżek do plików z QStringList
Forum Updated to NodeBB v4.3 + New Features

QPixmap - ładowanie ścieżek do plików z QStringList

Scheduled Pinned Locked Moved Polish
qpixmapqstringlist
3 Posts 2 Posters 2.1k 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.
  • 2 Offline
    2 Offline
    2Kris
    wrote on last edited by 2Kris
    #1

    Witam, tak, jak w temacie próbuje załadować listę ścieżek do obrazów z QStringList. Niestety, tylko dla ostatniej iteracji pętli przypisywana jest ścieżka, co ukazuje niniejsza wartość qDebug:

    QPixmap(null)
    QPixmap(null)
    QPixmap(null)
    QPixmap(null)
    QPixmap(QSize(1024, 768),depth=32,devicePixelRatio=1,cacheKey=0x5800000302)

    poniżej zamieszczam fragment kodu:

    void MainWindow::createPDF(QString fileName, QStringList imagePathList)
    {
        QPdfWriter pdfWriter(fileName);
        pdfWriter.setPageSize(QPagedPaintDevice::A4);
        bool newPage = false;
    
        QPainter painter;
        painter.begin(&pdfWriter);
    
        foreach(const QString &str, imagePathList)
        {
            QPixmap pixmap(str);
    
            if(newPage)
                pdfWriter.newPage();
            newPage = true;
    
            painter.drawPixmap(QRect(0,0,pdfWriter.logicalDpiX()*8.3,pdfWriter.logicalDpiY()*11.7),pixmap);
            qDebug() << pixmap;
        }
        painter.end();
    }
    

    Z góry dziękuję za pomoc i pozdrawiam.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      turaz
      wrote on last edited by turaz
      #2

      Jeśli jesteś przekonany, że w QStringList znajdują się ścieżki a nie puste QStringi to innym problemem może być:
      If the file does not exist or is of an unknown format, the pixmap becomes a null pixmap.
      źródło: dokumentacja

      1 Reply Last reply
      0
      • 2 Offline
        2 Offline
        2Kris
        wrote on last edited by
        #3

        Dzięki za szybką odpowiedź.
        Problem rozwiązany zamiast QPixmap, użyłem QImage i metody drawImage().
        Nadal nie mam pojęcia dlaczego QPixmap nie działa. QStringList zawiera ścieżki, a obrazy są formatu .jpg

        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