[Qt-interest] QUndoStack* in namespace -> SIGSEGV

Philipp Schmidt philschmidt at gmx.net
Sun Dec 6 09:18:08 CET 2009


Hi,

i want to have one global QUndoStack and have therefore declared it in the 
header file for the global namespace. In the Mainwindow i create a new 
QUndoStack Object but if i try to access it from yet another class i get a 
SIGSEGV since (according to gdb) the pointer doesn't yet have an address.

Maybe i am going about this the wrong way but since the documentation is quite 
small on this subject i didn't know how else to do ist.

Kind Regards
Philipp Schmidt

--namespace--

namespace foo {
	static QUndoStack *undostack;
}

--mainwindow--

using namespace foo;

MainWindow::MainWindow ( QWidget* parent, Qt::WindowFlags flags ) : QMainWindow 
( parent, flags ) {
...
	undostack = new QUndoStack();
	SubWindow w = new SubWindow(this);
	//add to layout etc...
}

--subWindow--

using namespace foo;

SubWindow::SubWindow ( QWidget* parent, Qt::WindowFlags f ) : QWidget ( 
parent, f ) {
...
	qDebug() << "undostack: " + undostack->count();
}



More information about the Qt-interest-old mailing list