PDA

View Full Version : Qt release conf problem



make
29th March 2012, 19:49
hi! I am not new to Qt, and usually i have not any problems with it or just solve them with documentation. But now i have a bit strange problem.
First i should say, that use Qt with MSVC2010 compiller. I have an app with 2 QWidgets (so with 2 ui forms). So in first widget i have a button, and when i push it, the second widget must appear. To initialize second form i use:



resWidget = new QWidget();
resUi->setupUi(resWidget);
resWidget->show();


So the problem is when i compile this app with debug configuration - all works good. But built with release configuration program stops working after pressing a button in the first widget. I debuged the app and the problem was in the line with "setupUi(...)" function.

P.S. One more interesting thing - if the second form is empty - it also runs good in both configurations.

aamer4yu
30th March 2012, 11:03
How did you make the two forms and their classes ? If you made with Qt creator you should get the classes yourself.
From the code it seems there must be some parenting issue with the forms. Its hard to tell exactly without knowing the complete code.
If you can post atleast the creation of widgets code, may be we can help more.

make
30th March 2012, 18:30
This is the part of code connected with creating GUI


stdafx.h


#ifndef STDAFX_H
#define STDAFX_H

#include <QWidget>
#include <QMessageBox>
#include <QFileDialog>
#include <QString>
#include <QPixmap>
#include <QTableWidgetItem>
#include <QList>
#include <QDir>
#include <QComboBox>

#include "ui_mainwidget.h"
#include "ui_result.h"

#include "imageprocessor.h"

#endif // STDAFX_H


MainWidget.h


#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include "stdafx.h"

namespace Ui
{
class MainWidget;
}

class MainWidget : public QWidget
{
Q_OBJECT

public:
explicit MainWidget(QWidget *parent = 0);
~MainWidget();

public slots:
void onLoadBtnClicked();
void onProcBtnClicked();
void onExportBtnClicked();
void onExportAllBtnClicked();
void onDeleteBtnClicked();
void onTabChanged();
void onMoveToGoodWndsBtnClicked();
void onMoveToBadWndsBtnClicked();

private:
Ui::MainWidget *ui;
Ui::ResWidget *resUi;
QWidget *resWidget;
ImageProcessor *imageProc;

void setResUi();
void showGoodWnds();
void showBadWnds();
};

#endif // MAINWIDGET_H


MainWidget.cpp


#include "mainwidget.h"

// CONSTRUCTORS

//
MainWidget::MainWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainWidget)
{
ui->setupUi(this);

// Connect buttons
QObject::connect(ui->loadBtn, SIGNAL(clicked()),
this, SLOT(onLoadBtnClicked()));
QObject::connect(ui->procBtn, SIGNAL(clicked()),
this, SLOT(onProcBtnClicked()));

imageProc = 0;
}

//
MainWidget::~MainWidget()
{
delete ui;
}

// SLOTS

//
void MainWidget::onProcBtnClicked()
{
if(0 == imageProc)
{
return;
}

setResUi();
showGoodWnds();
showBadWnds();
}

// PRIVATE FUNCTIONS

//
void MainWidget::setResUi()
{
// Load result window
resWidget = new QWidget();
resUi->setupUi(resWidget);
resWidget->show();

// Connect buttons of the result window
QObject::connect(resUi->closeBtn, SIGNAL(clicked()),
resWidget, SLOT(close()));
QObject::connect(resUi->exportBtn, SIGNAL(clicked()),
this, SLOT(onExportBtnClicked()));
QObject::connect(resUi->exportAllBtn, SIGNAL(clicked()),
this, SLOT(onExportAllBtnClicked()));
QObject::connect(resUi->deleteBtn, SIGNAL(clicked()),
this, SLOT(onDeleteBtnClicked()));
QObject::connect(resUi->tabWidget, SIGNAL(currentChanged(int)),
this, SLOT(onTabChanged()));
QObject::connect(resUi->moveToGoodBtn, SIGNAL(clicked()),
this, SLOT(onMoveToGoodWndsBtnClicked()));
QObject::connect(resUi->moveToBadBtn, SIGNAL(clicked()),
this, SLOT(onMoveToBadWndsBtnClicked()));

//
resUi->tabWidget->setCurrentIndex(GOOD_TAB);
resUi->moveToGoodBtn->setEnabled(false);
}



As i said, all works perfectly in DEBUG mode; in RELEASE mode prgram stoppes executing at line 49 in MainWidget.cpp module.
Please help me((((

make
1st April 2012, 20:35
OK)) I've solved the problem - just added one more class for the second form - and all is right!!! thanks...