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. Difference in release and debug versions

Difference in release and debug versions

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k 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.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    I have such code:
    @ImageWidget::ImageWidget( QWidget * parent, const QString & filename ) : QWidget(parent)
    {
    m_imageLabel = new QLabel();
    m_imageLabel->setBackgroundRole(QPalette::Base);
    m_imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    m_imageLabel->setScaledContents(true);

    m_scrollArea = new QScrollArea(this);
    m_scrollArea->setBackgroundRole(QPalette::Dark);
    m_scrollArea->setWidget(m_imageLabel);

    QVBoxLayout * layout = new QVBoxLayout();
    layout->addWidget(m_scrollArea);
    setLayout(layout);

    setWindowTitle(filename);
    resize(500, 400);

    // open file

    m_image = QImage(filename);
    if (m_image.isNull()) {
    QMessageBox::information(this, tr("Warning"),
    tr("Cannot load %1.").arg(filename));
    return;
    }

    m_imageLabel->setPixmap(QPixmap::fromImage(m_image));

    m_scaleFactor = 1.0;
    normalSize();

    m_pixelatorFlag = false;

    //connect(parent->ui.actionPixelator, SIGNAL(triggered()), this, SLOT(pixelatorOn()));

    m_difference = 20;
    m_currentColor = Qt::black;
    }@

    So when I run in debug I have m_image.isNull() = false, and program works correctle, but when making release and execute it on computer without Qt installed (I mean only my *.exe and core,gui dlls) m_image.isNull() = false. So m_image is QImage (not pointer), and filename gets here:

    @void MainWnd::onOpen()
    {
    QStringList files = QFileDialog::getOpenFileNames(this, "Select one or more files to open", "", "Images (*.png *.bmp *.jpeg *.jpg)");

    for(int i = 0; i<files.count();i++)
    createChildWindow(files.at(i));
    }@

    Then :

    @void MainWnd::createChildWindow(QString fileName)
    {
    ImageWidget * widget = new ImageWidget(this,fileName);
    connect(widget,SIGNAL(colorSelected(const QString & , int, int)),m_prcPanel, SLOT(showColorCoord(const QString &, int, int)));
    connect(m_prcPanel->m_difference,SIGNAL(valueChanged(int)),widget,SLOT(onChangeDifference(int)));

    QMdiSubWindow * window = m_area->addSubWindow(widget);
    if (window) {
    window->setAttribute(Qt::WA_DeleteOnClose, true);
    m_area->setActiveSubWindow(qobject_cast<QMdiSubWindow *>--(widget));
    widget->show();
    }
    }@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      maxim.prishchepa
      wrote on last edited by
      #2

      you can try do something like this:

      @bool isError = true;
      if(filename.isEmpty() == flase && QFile::exists(filename)){
      m_image = QImage(filename);
      if (m_image.isNull() == false)
      isError = false;
      }
      if(isError){
      QMessageBox::information(this, tr("Warning"),
      tr("Cannot load %1.").arg(filename));
      return;
      }
      }@

      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anticross
        wrote on last edited by
        #3

        This is not actually problem. I mean I need to know why this happens ? The filename is not empty but the QImage is clear.

        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