Pc 0x4 in read in psymtab, but not in symtab, while accesing status bar [Solved]
-
I've got a problem accesing status bar labels.
mainwindow.cpp
@#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "nowykosztorys.h"
#include "globalne.h"
#include <QLabel>
#include <QMenu>
#include <QFile>MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MainWindow::showMaximized();//Konstrukcja status bara QLabel *StatusOferta = new QLabel(this); QLabel *StatusKlient = new QLabel(this); QLabel *StatusObiekt = new QLabel(this); QLabel *StatusZmiana = new QLabel(this); statusBar()->addWidget(StatusOferta,10); statusBar()->addWidget(StatusKlient,20); statusBar()->addWidget(StatusObiekt,50); statusBar()->addWidget(StatusZmiana,20); StatusOferta->setAlignment(Qt::AlignCenter); StatusKlient->setAlignment(Qt::AlignCenter); StatusObiekt->setAlignment(Qt::AlignCenter); StatusZmiana->setAlignment(Qt::AlignCenter); //Tworzenie plików QFile Plik; Plik.setFileName("Klienci.txt"); Plik.open(QIODevice::WriteOnly | QIODevice::Append); Plik.close();
}
MainWindow::~MainWindow()
{
delete ui;
}void MainWindow::on_actionNowy_kosztorys_triggered()
{
NowyKosztorys iNowyKosztorys;
int T1;
T1=iNowyKosztorys.exec();
if (T1==1)
{
//StatusOferta->setText(OFERTA);
//StatusKlient->setText(KLIENT);
StatusObiekt->setText("test");
}
}@mainwindow.h
@#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include <QLabel>namespace Ui {
class MainWindow;
}class MainWindow : public QMainWindow
{
Q_OBJECTpublic:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();private slots:
void on_actionNowy_kosztorys_triggered();private:
Ui::MainWindow *ui;
QLabel *StatusOferta, *StatusKlient, *StatusObiekt, *StatusZmiana;};
#endif // MAINWINDOW_H@
If I want to setText on label deployed in statusbar outside MainWindow constructor(in above code in MainWindow::on_actionNowy_kosztorys_triggered() function) the MainWindow constructor, app hangs and debugger gives me this "Internal error: pc 0x4 in read in psymtab, but not in symtab". If I use same code inside constructor everything is fine.
I don't get it what is wrong.... -
Hi and welcome to devnet,
You are shadowing your member variables in the constructor.
See this "thread":http://qt-project.org/forums/viewthread/41061/ for more information
-
You're welcome !
Since it's all good now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)