It seems my project is kidding on me. The build gives various "unknown"(to me) errors. I'm getting angry, is it possible that QtCreator sucks and Qt Windows SDK sucks, too?
Here is all my code:
main_window.h
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QTabWidget>
#include <QVBoxLayout>
#include <QtSql>
#include <QListWidget>
{
Q_OBJECT
/// @name Special methods
public:
virtual ~main_window();
/// @name Helpers
private:
void complete_main_window();
private:
void create_tabs();
private:
void create_widgets();
void create_documents_widgets();
void create_keywords_widgets();
void create_references_widgets();
private:
private:
void setup_layout();
void setup_documents_layout();
void setup_keywords_layout();
void setup_references_layout();
private:
private:
void make_connections();
private:
void initialize_database();
void fill_contents();
void fill_documents_content();
void fill_keywords_content();
void fill_references_content();
private:
};
#endif // MAIN_WINDOW_H
#ifndef MAIN_WINDOW_H
#define MAIN_WINDOW_H
#include <QTabWidget>
#include <QVBoxLayout>
#include <QtSql>
#include <QListWidget>
class main_window : public QTabWidget
{
Q_OBJECT
/// @name Special methods
public:
main_window(QWidget* parent = 0);
virtual ~main_window();
/// @name Helpers
private:
void complete_main_window();
private:
void create_tabs();
private:
void create_widgets();
void create_documents_widgets();
void create_keywords_widgets();
void create_references_widgets();
private:
QWidget* m_documents;
QWidget* m_keywords;
QWidget* m_references;
private:
void setup_layout();
void setup_documents_layout();
void setup_keywords_layout();
void setup_references_layout();
private:
QVBoxLayout* m_documents_layout;
QVBoxLayout* m_keywords_layout;
QVBoxLayout* m_references_layout;
private:
void make_connections();
private:
void initialize_database();
void fill_contents();
void fill_documents_content();
void fill_keywords_content();
void fill_references_content();
private:
QSqlDatabase m_database;
QSqlQuery* m_query;
};
#endif // MAIN_WINDOW_H
To copy to clipboard, switch view to plain text mode
main_window.cpp
#include "main_window.h"
main_window
::main_window(QWidget* parent
){
create_widgets();
setup_layout();
create_tabs();
complete_main_window();
}
main_window::~main_window()
{
}
void main_window::complete_main_window()
{
showMaximized();
show();
}
void main_window::create_tabs()
{
addTab(m_documents, "Documents");
addTab(m_keywords, "Keywords");
addTab(m_references, "References");
}
void main_window::create_widgets()
{
create_documents_widgets();
create_keywords_widgets();
create_references_widgets();
}
void main_window::create_documents_widgets()
{
}
void main_window::create_keywords_widgets()
{
}
void main_window::create_references_widgets()
{
}
void main_window::setup_layout()
{
setup_documents_layout();
setup_keywords_layout();
setup_references_layout();
}
void main_window::setup_documents_layout()
{
m_documents->setLayout(m_documents_layout);
}
void main_window::setup_keywords_layout()
{
m_keywords->setLayout(m_keywords_layout);
}
void main_window::setup_references_layout()
{
m_references->setLayout(m_references_layout);
}
void main_window::make_connections()
{
}
void main_window::initialize_database()
{
m_database.setDatabaseName("main_database.sqlite");
if (!m_database.open()) {
qDebug() << "Can't open DB";
}
}
void main_window::fill_contents()
{
fill_documents_content();
fill_keywords_content();
fill_references_content();
}
void main_window::fill_documents_content()
{
// logic here
}
void main_window::fill_keywords_content()
{
//logic here
}
void main_window::fill_references_content()
{
//logic here
}
#include "main_window.h"
main_window::main_window(QWidget* parent)
: QTabWidget(parent)
{
create_widgets();
setup_layout();
create_tabs();
complete_main_window();
}
main_window::~main_window()
{
}
void main_window::complete_main_window()
{
showMaximized();
show();
}
void main_window::create_tabs()
{
addTab(m_documents, "Documents");
addTab(m_keywords, "Keywords");
addTab(m_references, "References");
}
void main_window::create_widgets()
{
create_documents_widgets();
create_keywords_widgets();
create_references_widgets();
}
void main_window::create_documents_widgets()
{
m_documents = new QWidget(this);
}
void main_window::create_keywords_widgets()
{
m_keywords = new QWidget(this);
}
void main_window::create_references_widgets()
{
m_references = new QWidget(this);
}
void main_window::setup_layout()
{
setup_documents_layout();
setup_keywords_layout();
setup_references_layout();
}
void main_window::setup_documents_layout()
{
m_documents_layout = new QVBoxLayout(this);
m_documents->setLayout(m_documents_layout);
}
void main_window::setup_keywords_layout()
{
m_keywords_layout = new QVBoxLayout(this);
m_keywords->setLayout(m_keywords_layout);
}
void main_window::setup_references_layout()
{
m_references_layout = new QVBoxLayout(this);
m_references->setLayout(m_references_layout);
}
void main_window::make_connections()
{
}
void main_window::initialize_database()
{
m_database = QSqlDatabase::addDatabase("QSQLITE");
m_database.setDatabaseName("main_database.sqlite");
if (!m_database.open()) {
qDebug() << "Can't open DB";
}
m_query = new QSqlQuery(m_database);
}
void main_window::fill_contents()
{
fill_documents_content();
fill_keywords_content();
fill_references_content();
}
void main_window::fill_documents_content()
{
// logic here
}
void main_window::fill_keywords_content()
{
//logic here
}
void main_window::fill_references_content()
{
//logic here
}
To copy to clipboard, switch view to plain text mode
And, finally, main.cpp
#include <QApplication>
#include "main_window.h"
int main(int argc, char** argv)
{
main_window w;
w.show();
return app.exec();
}
#include <QApplication>
#include "main_window.h"
int main(int argc, char** argv)
{
QApplication app(argc, argv);
main_window w;
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
I got the following output (for now, I'm sure if I change something, even add a comment, the errors will increase ):
unning build steps for project my_project...
Configuration unchanged, skipping qmake step.
Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/vardg/Documents/qt_projects/my_project-build-desktop'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\ActiveQt" -I"debug" -I"..\my_project" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\mkspecs\win32-g++" -o debug\main.o ..\my_project\main.cpp
In file included from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql/qsqlrelationaldelegate.h:48,
from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql/QtSql:15,
from ..\my_project\/main_window.h:6,
from ..\my_project\main.cpp:4:
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qlistview.h:57: error: redefinition of 'class
QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qwidget.h:141: error: previous definition of 'class
QWidget' In file included from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/QListWidget:1,
from ..\my_project\/main_window.h:7,
from ..\my_project\main.cpp:4:
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:202: error: redefinition of 'class
QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qwidget.h:141: error: previous definition of 'class
QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:308: error: no 'void QWidget::removeItemWidget(QListWidgetItem*)' member function declared in class 'QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:311: error: no 'void QWidget::addItem(QListWidgetItem*)' member function declared in class 'QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:314: error: no 'QListWidgetItem* QWidget::itemAt(int,
int) const' member function declared in class 'QWidget' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'void QListWidgetItem::setSelected(bool)': c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:318: error: 'class
QWidget' has no member named 'setItemSelected
' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'bool QListWidgetItem::isSelected() const': c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:321: error: 'class
QWidget' has no member named 'isItemSelected
' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'void QListWidgetItem::setHidden(bool)': c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:324: error: 'class
QWidget' has no member named 'setItemHidden
' c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'bool QListWidgetItem::isHidden() const': c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:327: error: 'class
QWidget' has no member named 'isItemHidden
' mingw32-make[1]: Leaving directory `C:/Users/vardg/Documents/qt_projects/my_project-build-desktop'
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project my_project(target: Desktop)
When executing build step 'Make'
unning build steps for project my_project...
Configuration unchanged, skipping qmake step.
Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Users/vardg/Documents/qt_projects/my_project-build-desktop'
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCore" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include" -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\ActiveQt" -I"debug" -I"..\my_project" -I"." -I"c:\QtSDK\Desktop\Qt\4.7.3\mingw\mkspecs\win32-g++" -o debug\main.o ..\my_project\main.cpp
In file included from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql/qsqlrelationaldelegate.h:48,
from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtSql/QtSql:15,
from ..\my_project\/main_window.h:6,
from ..\my_project\main.cpp:4:
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qlistview.h:57: error: redefinition of 'class QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qwidget.h:141: error: previous definition of 'class QWidget'
In file included from c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/QListWidget:1,
from ..\my_project\/main_window.h:7,
from ..\my_project\main.cpp:4:
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:202: error: redefinition of 'class QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include/QtGui/qwidget.h:141: error: previous definition of 'class QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:308: error: no 'void QWidget::removeItemWidget(QListWidgetItem*)' member function declared in class 'QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:311: error: no 'void QWidget::addItem(QListWidgetItem*)' member function declared in class 'QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:314: error: no 'QListWidgetItem* QWidget::itemAt(int, int) const' member function declared in class 'QWidget'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'void QListWidgetItem::setSelected(bool)':
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:318: error: 'class QWidget' has no member named 'setItemSelected'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'bool QListWidgetItem::isSelected() const':
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:321: error: 'class QWidget' has no member named 'isItemSelected'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'void QListWidgetItem::setHidden(bool)':
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:324: error: 'class QWidget' has no member named 'setItemHidden'
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h: In member function 'bool QListWidgetItem::isHidden() const':
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtGui/qlistwidget.h:327: error: 'class QWidget' has no member named 'isItemHidden'
mingw32-make[1]: Leaving directory `C:/Users/vardg/Documents/qt_projects/my_project-build-desktop'
mingw32-make[1]: *** [debug/main.o] Error 1
mingw32-make: *** [debug] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project my_project(target: Desktop)
When executing build step 'Make'
To copy to clipboard, switch view to plain text mode
Here is, just in case, the .pro file
QT += core gui sql
TARGET = my_project
TEMPLATE = app
SOURCES += main.cpp\
main_window.cpp
HEADERS += main_window.h
QT += core gui sql
TARGET = my_project
TEMPLATE = app
SOURCES += main.cpp\
main_window.cpp
HEADERS += main_window.h
To copy to clipboard, switch view to plain text mode
Extra great thanks in advance, also thanks for previous replies, waiting for solution....
Bookmarks