Results 1 to 3 of 3

Thread: problem with .bmp

  1. #1
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Arrow problem with .bmp

    Hello,

    I have a problem! My images are .bmp. I have loaded them to my new proyect giving a new name as you did "00b.qrc"... and then, in the place that you set in note of test.cpp:


    Qt Code:
    1. const QString bin = QString::number(r) + QString::number(c) + "b.png";
    2. const QString fin = QString::number(r) + QString::number(c) + "f.png";
    To copy to clipboard, switch view to plain text mode 

    I change for :
    Qt Code:
    1. const QString bin = QString::number(r) + QString::number(c) + "b.bmp";
    2. const QString fin = QString::number(r) + QString::number(c) + "f.bmp";
    To copy to clipboard, switch view to plain text mode 

    What I'm doing wrong?
    Last edited by wysota; 2nd July 2009 at 08:53. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with .bmp

    Quote Originally Posted by IRON_MAN View Post
    I have loaded them to my new proyect giving a new name as you did "00b.qrc"...
    As who did? And have you a image plugin that support bmp files?

  3. #3
    Join Date
    Jun 2009
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem with .bmp

    The code is the following one. With another aplications I can work with images .bmp

    Qt Code:
    1. #include <QtGui>
    2. #include "test.h"
    3.  
    4. Test::Test(QWidget *parent)
    5. : QDialog(parent), m_rows(5), m_columns(2)
    6. {
    7. m_gl = new QGridLayout(this);
    8. init();
    9. }
    10.  
    11. void Test::init()
    12. {
    13. for (int r = 0; r < m_rows; ++r) {
    14. for (int c = 0; c < m_columns; ++c) {
    15. QPushButton *pb = new QPushButton();
    16. pb->setProperty("state", Background);
    17. const QString bin = QString::number(r) + QString::number(c) + "b.png";
    18. const QString fin = QString::number(r) + QString::number(c) + "f.png";
    19.  
    20. QPixmap fp(10, 10);
    21. fp.fill(QColor(qrand()%255, qrand()%255, qrand()%255));
    22. fp.save(fin);//must be optimized
    23.  
    24. QPixmap bp(10, 10);
    25. bp.fill(QColor(qrand()%255, qrand()%255, qrand()%255));
    26. bp.save(bin);//must be optimized
    27.  
    28. pb->setProperty("backgroundImageName", bin);
    29. pb->setProperty("foregroundImageName", fin);
    30. //pb->setText("Background");
    31. pb->setIcon(QIcon(bp));
    32. connect(pb, SIGNAL(clicked()), SLOT(changeImage()));
    33. m_gl->addWidget(pb, r, c);
    34. }
    35. }
    36. }
    37.  
    38. void Test::changeImage()
    39. {
    40. QPushButton *pb = qobject_cast<QPushButton *>(sender());
    41. if (!pb)
    42. return;
    43. const State state = State(pb->property("state").toInt());
    44. // pb->setText(state == Background ? "Foreground" : "Background");
    45. pb->setProperty("state", state == Background ? Foreground : Background);
    46. const QString fileName = (state == Background ? pb->property("foregroundImageName").toString() : pb->property("backgroundImageName").toString());
    47. pb->setIcon(QIcon(fileName));
    48. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 2nd July 2009 at 08:53. Reason: missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 23rd April 2009, 09:05
  2. Replies: 19
    Last Post: 3rd April 2009, 23:17
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 11:21
  5. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36

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.