Results 1 to 8 of 8

Thread: QDataWidgetMapper & QLabel

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2006
    Posts
    25
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDataWidgetMapper & QLabel

    Hello,

    I'm using QTableView to consult records and a QDialog for modify the records. In QTableView I use QItemDelegate for see images, that are saved in bytea format in postgresql database. I have obtained put the image in database in byte format:

    Qt Code:
    1. if (ui.qLnFitxerSel->text().length()>0)
    2. {
    3. QPixmap pixmap(ui.qLnFitxerSel->text(), "PNG" );
    4. QByteArray bytes;
    5. QBuffer buffer(&bytes);
    6. buffer.open(QIODevice::WriteOnly);
    7. pixmap.save(&buffer, "PNG");
    8.  
    9. qSqlTableModel->setData(q->getAKSqlTableModel()->index(row,
    10. akFrontData->getAKSqlTableModel()->fieldIndex("bandera")), bytes);
    11. }
    To copy to clipboard, switch view to plain text mode 

    In my Qdialog I want to see the Image trought QLabel and I use the QDataWidgetMapper but this returns me the Image in byte information
    so I see the QLabel something like this: PNG..![]... how I could do that
    when QDataWidgetMapper return's me the information of qlabel it converts
    it as Image and not in text, setting qLabel as QPixmap.



    Qt Code:
    1. void AKEntitat::mapFields(QSqlQueryModel * model)
    2. {
    3. QSqlRecord qSqlRecord = model->record();
    4.  
    5. int count = qSqlRecord.count();
    6.  
    7. for (int i=0; i<=count; i++)
    8. {
    9. QSqlField qSqlCamp = qSqlRecord.field(i);
    10.  
    11. akCampBd = searchAKCampBd(qSqlCamp.name());
    12. qLabel = searchLabel(qSqlCamp.name());
    13.  
    14. if (akCampBd!=0)
    15. {
    16. qDataWidgetMapper->addMapping(akCampBd->akCamp, i);
    17. }
    18.  
    19. if (qLabel!=0)
    20. {
    21. qDataWidgetMapper->addMapping(qLabel, i);
    22.  
    23. }
    24. }
    25.  
    26. qDataWidgetMapper->toFirst();
    27.  
    28. connect(akTaula->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
    29. qDataWidgetMapper, SLOT(setCurrentModelIndex(QModelIndex)));
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 

    Thank you
    Last edited by wysota; 9th November 2007 at 09:55. Reason: missing [code] tags

Similar Threads

  1. Problem with QLabel and setText
    By jambrek in forum Qt Programming
    Replies: 7
    Last Post: 31st October 2007, 16:02
  2. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47
  3. QLabel links?
    By gfunk in forum Qt Programming
    Replies: 3
    Last Post: 23rd December 2006, 00:42
  4. QScrollArea display custom QLabel
    By spawnwj in forum Qt Programming
    Replies: 6
    Last Post: 6th December 2006, 03:38
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 19:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.