[Solved]Project suddenly doesn't compile
-
From what I know my Qt Hearders haven't been modified. What is the issue then?
-
Yes exactly the same in release mode
-
Here the code
#ifndef PANELSTACK_H #define PANELSTACK_H #include <QWidget> #include <QLabel> #include <QStack> #include <QStackedWidget> #include "abstractpanel.h" class PanelStack : public QWidget { Q_OBJECT public: static PanelStack *instance(); int addPanel( AbstractPanel* ); void showPanel( int ); PanelStack(); public slots: void home(); void back(); private: static PanelStack *m_instance; void showTopPanel(); // QLabel *m_titleLabel; QStackedWidget *m_panelStack; QStack<int> m_history; }; #endif // PANELSTACK_H #include "panelstack.h" #include "abstractpanel.h" #include <QStackedWidget> #include <QGridLayout> PanelStack *PanelStack::m_instance = 0; PanelStack *PanelStack::instance() { if( !m_instance ) m_instance = new PanelStack(); return m_instance; } int PanelStack::addPanel( AbstractPanel *panel ) { return m_panelStack->addWidget( panel ); } void PanelStack::showPanel( int index ) { m_history.push( index ); showTopPanel(); } void PanelStack::showTopPanel() { m_panelStack->setCurrentIndex( m_history.top() ); AbstractPanel *panel = dynamic_cast<AbstractPanel*>( m_panelStack->widget( m_history.top() ) ); panel->enterPanel(); // m_titleLabel->setText( panel->titleText() ); } PanelStack::PanelStack() : QWidget() { //m_titleLabel = new QLabel(); //m_titleLabel->setAlignment( Qt::AlignCenter ); m_panelStack = new QStackedWidget(); QGridLayout *layout = new QGridLayout( this ); //layout->addWidget( m_titleLabel, 0, 0 ); layout->addWidget( m_panelStack, 1, 0 ); } void PanelStack::back() { if( m_history.count() <= 1 ) return; // Cannot go back past the first panel m_history.pop(); showTopPanel(); } void PanelStack::home() { if( m_history.count() <= 1 ) return; // Cannot go home if there are no panels, and is already home if there is only one panel while( m_history.count() > 1 ) m_history.pop(); showTopPanel(); }
-
Did you check the content of QStack.h ?
-
I did check the content of Qstack.h
QStack.h
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** As a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QSTACK_H #define QSTACK_H #include <QtCore/qvector.h> QT_BEGIN_NAMESPACE template<class T> class QStack : public QVector<T> { public: inline QStack() {} inline ~QStack() {} inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps inline void push(const T &t) { QVector<T>::append(t); } T pop(); T &top(); const T &top() const; }; template<class T> inline T QStack<T>::pop() { Q_ASSERT(!this->isEmpty()); T t = this->data()[this->size() -1]; this->resize(this->size()-1); return t; } template<class T> inline T &QStack<T>::top() { Q_ASSERT(!this->isEmpty()); this->detach(); return this->data()[this->size()-1]; } template<class T> inline const T &QStack<T>::top() const { Q_ASSERT(!this->isEmpty()); return this->data()[this->size()-1]; } QT_END_NAMESPACE #endif // QSTACK_H
-
Abstract Panel
#ifndef ABSTRACTPANEL_H #define ABSTRACTPANEL_H #include <QWidget> class AbstractPanel:public QWidget { public: virtual void enterPanel() {} //virtual QString titleText() const = 0; protected: AbstractPanel(); void addPanelToStack(); int panelIndex() const; private: int m_panelIndex; }; #endif // ABSTRACTPANEL_H #include "abstractpanel.h" #include "panelstack.h" AbstractPanel::AbstractPanel():QWidget() { } void AbstractPanel::addPanelToStack() { m_panelIndex = PanelStack::instance()->addPanel( this ); } int AbstractPanel::panelIndex() const { return m_panelIndex; }
-
Thank you. I have found the error. I've missed a bracket and a semi colon in one of my header file