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

André Somers andre at familiesomers.nl
Sun Dec 6 11:10:09 CET 2009


May I recommend a singleton pattern here?

André


-----Oorspronkelijk bericht-----
Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Philipp Schmidt
Verzonden: zondag 6 december 2009 9:18
Aan: qt-interest at trolltech.com
Onderwerp: [Qt-interest] QUndoStack* in namespace -> SIGSEGV

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();
}
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest





More information about the Qt-interest-old mailing list