KDevelop+Qt

IDE, VCS и прочее

Модератор: Модераторы разделов

Sleek
Сообщения: 9

KDevelop+Qt

Сообщение Sleek »

Делаю в KDevelop HelloWorld:

Код: Выделить всё

#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
 {
     QApplication app(argc, argv);
     QLabel *label = new QLabel("Hello Qt!");
     label->show();
     return app.exec();
 }

При компиляции получается вот такое:

Код: Выделить всё

cd '/home/qt/tst' && gmake -k
cd src/ && gmake -f Makefile
компиляция main.cpp (g++)
main.cpp:22:24: error: QApplication: Нет такого файла или каталога
main.cpp:23:18: error: QLabel: Нет такого файла или каталога
main.cpp: In function ‘int main(int, char**)’:
main.cpp:26: error: ‘QApplication’ was not declared in this scope
main.cpp:26: error: expected `;' before ‘app’
main.cpp:27: error: ‘QLabel’ was not declared in this scope
main.cpp:27: error: ‘label’ was not declared in this scope
main.cpp:27: error: expected type-specifier before ‘QLabel’
main.cpp:27: error: expected `;' before ‘QLabel’
main.cpp:29: error: ‘app’ was not declared in this scope
main.cpp: At global scope:
main.cpp:24: warning: unused parameter ‘argc’
main.cpp:24: warning: unused parameter ‘argv’
gmake[1]: *** [main.o] Ошибка 1
gmake[1]: Цель `first' не была пересобрана из-за ошибок.
gmake: *** [sub-src-make_default] Ошибка 2
gmake: Цель `first' не была пересобрана из-за ошибок.
*** Завершено с кодом: 2 ***

Захожу в консоль, набираю

Код: Выделить всё

qmake -project
qmake
make

Все собирается на ура.
Как мне "объяснить" KDevelop, чтобы он вместо cd '/home/qt/tst' && gmake -k делал то что написано выше? или может еще есть другие варианты решения?
Спасибо сказали:
Аватара пользователя
eduard_pustobaev
Сообщения: 2629
Статус: Ленивец
ОС: Arch/Debian.

Re: KDevelop+Qt

Сообщение eduard_pustobaev »

Создавать qmake-based проект. С ними как-бы всё ок.
В дисгармонии со вселенной.
Спасибо сказали:
Sleek
Сообщения: 9

Re: KDevelop+Qt

Сообщение Sleek »

Я создаю C++ -> QMake Project -> Basic Qt4 Application. Это ж оно?
Спасибо сказали:
Аватара пользователя
Shura
Сообщения: 1537
Статус: Оказывается и без KDE есть жизнь
ОС: FreeBSD 8.0-RC2

Re: KDevelop+Qt

Сообщение Shura »

вместо
#include <QApplication>
#include <QLabel>

пиши

Код: Выделить всё

#include <QtGui/QApplication>
#include <QtGui/QLabel>
Rock'n'roll мертв © БГ
Спасибо сказали:
Аватара пользователя
eduard_pustobaev
Сообщения: 2629
Статус: Ленивец
ОС: Arch/Debian.

Re: KDevelop+Qt

Сообщение eduard_pustobaev »

Sleek писал(а):
19.02.2008 13:25
Это ж оно?

Оно. А путь к qmake правильно указываете при создании?

Shura писал(а):
19.02.2008 18:21
вместо
#include <QApplication>
#include <QLabel>

пиши

Код: Выделить всё

#include <QtGui/QApplication>
#include <QtGui/QLabel>


А вот это как раз необязательно. Никогда не было из-за этого проблем.
Правда есть в qmake manager настройка какие модули Qt использовать, может там не отмечен QtGui...
В дисгармонии со вселенной.
Спасибо сказали:
Аватара пользователя
Shura
Сообщения: 1537
Статус: Оказывается и без KDE есть жизнь
ОС: FreeBSD 8.0-RC2

Re: KDevelop+Qt

Сообщение Shura »

У меня как раз были проблемы из-за этого. Справился именно таким образом.
Rock'n'roll мертв © БГ
Спасибо сказали:
Sleek
Сообщения: 9

Re: KDevelop+Qt

Сообщение Sleek »

Shura писал(а):
19.02.2008 18:21
вместо
#include <QApplication>
#include <QLabel>

пиши

Код: Выделить всё

#include <QtGui/QApplication>
#include <QtGui/QLabel>


тогда оно их находит, но скомпилировать все равно не может :(

Код: Выделить всё

main.cpp:(.text+0x36): undefined reference to `QApplication::QApplication(int&, char**, int)'
main.cpp:(.text+0x80): undefined reference to `QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)'
main.cpp:(.text+0xaf): undefined reference to `QApplication::exec()'
main.cpp:(.text+0xb9): undefined reference to `QApplication::~QApplication()'
main.cpp:(.text+0xd8): undefined reference to `QApplication::~QApplication()'


eduard_pustobaev писал(а):
19.02.2008 19:26
А путь к qmake правильно указываете при создании?

Да. /usr/bin/qmake

Код: Выделить всё

/usr/bin/qmake -v
QMake version 2.01a
Using Qt version 4.3.1 in /usr/lib


eduard_pustobaev писал(а):
19.02.2008 19:26
Правда есть в qmake manager настройка какие модули Qt использовать, может там не отмечен QtGui...

А можно подробнее, где это?

Все собирается нормально, если предварительно запустить qmake -project, но только вот если при этом проект открыт в KDevelop, то KDevelop потом вылетает. :huh:
Спасибо сказали:
Аватара пользователя
Shura
Сообщения: 1537
Статус: Оказывается и без KDE есть жизнь
ОС: FreeBSD 8.0-RC2

Re: KDevelop+Qt

Сообщение Shura »

тогда оно их находит, но скомпилировать все равно не может

Компилировать-то компилирует. Слинковать не может.
Тут уже нужно подключать библиотеку lQtGui.
Rock'n'roll мертв © БГ
Спасибо сказали:
Аватара пользователя
eduard_pustobaev
Сообщения: 2629
Статус: Ленивец
ОС: Arch/Debian.

Re: KDevelop+Qt

Сообщение eduard_pustobaev »

Sleek писал(а):
22.02.2008 01:49
А можно подробнее, где это?

В Kdevelop. У меня на тулбаре справа... :)
В дисгармонии со вселенной.
Спасибо сказали:
Аватара пользователя
n37g0d
Сообщения: 65
ОС: debian5

Re: KDevelop+Qt

Сообщение n37g0d »

обсолютно таже проблема, если "тут" есть решение, то можно "разжевать"? я просто программер под винду, переползающий в линукс и первый раз поставил kdevelop и никак не могу настроить, естественно пути всяких там библиотек еще знаю не очень.

Вообщем создаю пример qmake проекта, который использует qt, из визарда, он уже создается с mainwindow и т.п. и при попытке собрать получаю теже самые ошибки, якобы не может найти файлы .h .

зашел в свойства проекта\поддержка с++\qt\ поставил галочку "проект использует qt", выбрал 4.х, и в основной путь установки qt указал /usr/include/qt4 . Это не помогло, по прежнему теже самые ошибки.

дописывать в каждый хедер файл имя его раздела не хочу, т.к. это бред, помнить разделы... тем более что проекты на qt написанные мной раннее, без этих разделов обсолютно нормально компиляться через консоль. Т.е. проблема только в kdevelop.

Я где-то что-то не так указываю или где-то что-то еще надо указать? в qmake manager, в свойствах подпроекта есть возможность подключать библиотеки, указыать зависимости и т.п. но я не знаю что и куда там подключать... Помогите пожалуйста.

десткоп gnome, qt4, debian, kdevelop 3.3.5, проекты qt из любой папки нормально собираются через консоль (стандартными 3мя командами).
Спасибо сказали:
Аватара пользователя
n37g0d
Сообщения: 65
ОС: debian5

Re: KDevelop+Qt

Сообщение n37g0d »

На всякий случай, вот список инклюдов после работы визарда кдевелоп:

Код: Выделить всё

#include "mytest.h"

#include <qimage.h>
#include <qpixmap.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qpopupmenu.h>
#include <qmenubar.h>
#include <qtextedit.h>
#include <qfile.h>
#include <qfiledialog.h>
#include <qstatusbar.h>
#include <qmessagebox.h>
#include <qprinter.h>
#include <qapplication.h>
#include <qaccel.h>
#include <qtextstream.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
#include <qwhatsthis.h>

#include "filesave.xpm"
#include "fileopen.xpm"
#include "fileprint.xpm"


а вот вывод при сборке:

Код: Выделить всё

cd '/home/aleksey/qttest' && make -j1
cd src && make -f Makefile
/usr/bin/qmake -unix -o Makefile src.pro
g++ -c -pipe -O2 -D_REENTRANT -Wall -W -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o qttest.o qttest.cpp
qttest.cpp:28:24: error: qpopupmenu.h: No such file or directory
qttest.cpp:37:20: error: qaccel.h: No such file or directory
qttest.cpp:40:33: error: qpaintdevicemetrics.h: No such file or directory
qttest.cpp: In constructor ‘qttest::qttest()’:
qttest.cpp:48: error: ‘WDestructiveClose’ was not declared in this scope
qttest.cpp:53: error: no matching function for call to ‘QToolBar::QToolBar(qttest* const, const char [16])’
/usr/include/qt4/QtGui/qtoolbar.h:138: note: candidates are: QToolBar::QToolBar(const QToolBar&)
/usr/include/qt4/QtGui/qtoolbar.h:60: note: QToolBar::QToolBar(QWidget*)
/usr/include/qt4/QtGui/qtoolbar.h:59: note: QToolBar::QToolBar(const QString&, QWidget*)
qttest.cpp:54: error: ‘class QToolBar’ has no member named ‘setLabel’
qttest.cpp:59: error: no matching function for call to ‘QToolButton::QToolButton(QPixmap&, QString, const QString::Null&, qttest* const, const char [10], QToolBar*&, const char [10])’
/usr/include/qt4/QtGui/qtoolbutton.h:107: note: candidates are: QToolButton::QToolButton(const QToolButton&)
/usr/include/qt4/QtGui/qtoolbutton.h:91: note: QToolButton::QToolButton(QToolButtonPrivate&, QWidget*)
/usr/include/qt4/QtGui/qtoolbutton.h:56: note: QToolButton::QToolButton(QWidget*)
qttest.cpp:64: error: no matching function for call to ‘QToolButton::QToolButton(QPixmap&, QString, const QString::Null&, qttest* const, const char [8], QToolBar*&, const char [10])’
/usr/include/qt4/QtGui/qtoolbutton.h:107: note: candidates are: QToolButton::QToolButton(const QToolButton&)
/usr/include/qt4/QtGui/qtoolbutton.h:91: note: QToolButton::QToolButton(QToolButtonPrivate&, QWidget*)
/usr/include/qt4/QtGui/qtoolbutton.h:56: note: QToolButton::QToolButton(QWidget*)
qttest.cpp:69: error: no matching function for call to ‘QToolButton::QToolButton(QPixmap&, QString, const QString::Null&, qttest* const, const char [9], QToolBar*&, const char [11])’
/usr/include/qt4/QtGui/qtoolbutton.h:107: note: candidates are: QToolButton::QToolButton(const QToolButton&)
/usr/include/qt4/QtGui/qtoolbutton.h:91: note: QToolButton::QToolButton(QToolButtonPrivate&, QWidget*)
/usr/include/qt4/QtGui/qtoolbutton.h:56: note: QToolButton::QToolButton(QWidget*)
qttest.cpp:72: error: ‘whatsThisButton’ is not a member of ‘QWhatsThis’
qttest.cpp:79: error: ‘add’ is not a member of ‘QWhatsThis’
qttest.cpp:81: error: ‘QMimeSourceFactory’ has not been declared
qttest.cpp:88: error: ‘add’ is not a member of ‘QWhatsThis’
qttest.cpp:94: error: ‘add’ is not a member of ‘QWhatsThis’
qttest.cpp:97: error: ‘QPopupMenu’ was not declared in this scope
qttest.cpp:97: error: ‘file’ was not declared in this scope
qttest.cpp:97: error: expected type-specifier before ‘QPopupMenu’
qttest.cpp:97: error: expected `;' before ‘QPopupMenu’
qttest.cpp:98: error: ‘class QMenuBar’ has no member named ‘insertItem’
qttest.cpp:101: error: ‘CTRL’ was not declared in this scope
qttest.cpp:101: error: ‘Key_N’ was not declared in this scope
qttest.cpp:105: error: ‘Key_O’ was not declared in this scope
qttest.cpp:109: error: ‘Key_S’ was not declared in this scope
qttest.cpp:118: error: ‘Key_P’ was not declared in this scope
qttest.cpp:123: error: ‘Key_W’ was not declared in this scope
qttest.cpp:125: error: ‘Key_Q’ was not declared in this scope
qttest.cpp:127: error: no matching function for call to ‘QMenuBar::insertSeparator()’
/usr/include/qt4/QtGui/qmenubar.h:64: note: candidates are: QAction* QMenuBar::insertSeparator(QAction*)
qttest.cpp:129: error: ‘help’ was not declared in this scope
qttest.cpp:129: error: expected type-specifier before ‘QPopupMenu’
qttest.cpp:129: error: expected `;' before ‘QPopupMenu’
qttest.cpp:130: error: ‘class QMenuBar’ has no member named ‘insertItem’
qttest.cpp:132: error: ‘Key_F1’ was not declared in this scope
qttest.cpp:135: error: ‘SHIFT’ was not declared in this scope
qttest.cpp:137: error: no matching function for call to ‘QTextEdit::QTextEdit(qttest* const, const char [7])’
/usr/include/qt4/QtGui/qtextedit.h:374: note: candidates are: QTextEdit::QTextEdit(const QTextEdit&)
/usr/include/qt4/QtGui/qtextedit.h:286: note: QTextEdit::QTextEdit(QTextEditPrivate&, QWidget*)
/usr/include/qt4/QtGui/qtextedit.h:109: note: QTextEdit::QTextEdit(const QString&, QWidget*)
/usr/include/qt4/QtGui/qtextedit.h:108: note: QTextEdit::QTextEdit(QWidget*)
qttest.cpp:140: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘void qttest::newDoc()’:
qttest.cpp:156: error: ‘class qttest’ has no member named ‘setCaption’
qttest.cpp: In member function ‘void qttest::choose()’:
qttest.cpp:163: error: no matching function for call to ‘QFileDialog::getOpenFileName(const QString::Null&, const QString::Null&, qttest* const)’
/usr/include/qt4/QtGui/qfiledialog.h:144: note: candidates are: static QString QFileDialog::getOpenFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFlags<QFileDialog::Option>)
qttest.cpp:167: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘void qttest::load(const QString&)’:
qttest.cpp:174: error: ‘IO_ReadOnly’ was not declared in this scope
qttest.cpp:178: error: no matching function for call to ‘QTextStream::read()’
/usr/include/qt4/QtCore/qtextstream.h:119: note: candidates are: QString QTextStream::read(qint64)
qttest.cpp:179: error: ‘class QTextEdit’ has no member named ‘setModified’
qttest.cpp:180: error: ‘setCaption’ was not declared in this scope
qttest.cpp:181: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘void qttest::save()’:
qttest.cpp:192: error: ‘class QTextEdit’ has no member named ‘text’
qttest.cpp:194: error: ‘IO_WriteOnly’ was not declared in this scope
qttest.cpp:195: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp:204: error: ‘class QTextEdit’ has no member named ‘setModified’
qttest.cpp:206: error: ‘setCaption’ was not declared in this scope
qttest.cpp:208: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘void qttest::saveAs()’:
qttest.cpp:215: error: no matching function for call to ‘QFileDialog::getSaveFileName(const QString::Null&, const QString::Null&, qttest* const)’
/usr/include/qt4/QtGui/qfiledialog.h:151: note: candidates are: static QString QFileDialog::getSaveFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFlags<QFileDialog::Option>)
qttest.cpp:220: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘void qttest::print()’:
qttest.cpp:231: error: ‘class QPrinter’ has no member named ‘setup’
qttest.cpp:232: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp:240: error: ‘QPaintDeviceMetrics’ was not declared in this scope
qttest.cpp:240: error: expected `;' before ‘metrics’
qttest.cpp:242: error: ‘class QTextEdit’ has no member named ‘lines’
qttest.cpp:243: error: ‘metrics’ was not declared in this scope
qttest.cpp:247: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp:252: error: ‘metrics’ was not declared in this scope
qttest.cpp:253: error: ‘ExpandTabs’ was not declared in this scope
qttest.cpp:253: error: ‘DontClip’ was not declared in this scope
qttest.cpp:254: error: ‘class QTextEdit’ has no member named ‘text’
qttest.cpp:258: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp:260: error: ‘class QStatusBar’ has no member named ‘message’
qttest.cpp: In member function ‘virtual void qttest::closeEvent(QCloseEvent*)’:
qttest.cpp:266: error: ‘class QTextEdit’ has no member named ‘isModified’
qttest.cpp:267: error: invalid use of undefined type ‘struct QCloseEvent’
/usr/include/qt4/QtGui/qwidget.h:63: error: forward declaration of ‘struct QCloseEvent’
qttest.cpp:278: error: invalid use of undefined type ‘struct QCloseEvent’
/usr/include/qt4/QtGui/qwidget.h:63: error: forward declaration of ‘struct QCloseEvent’
qttest.cpp:281: error: invalid use of undefined type ‘struct QCloseEvent’
/usr/include/qt4/QtGui/qwidget.h:63: error: forward declaration of ‘struct QCloseEvent’
qttest.cpp:285: error: invalid use of undefined type ‘struct QCloseEvent’
/usr/include/qt4/QtGui/qwidget.h:63: error: forward declaration of ‘struct QCloseEvent’
make[1]: *** [qttest.o] Ошибка 1
make: *** [sub-src-make_default] Ошибка 2
*** Завершено с кодом: 2 ***
Спасибо сказали:
Аватара пользователя
n37g0d
Сообщения: 65
ОС: debian5

Re: KDevelop+Qt

Сообщение n37g0d »

так, извиняюсь, уже начинаю думать что визард у кдевелоп "не совсем такой"... попробовал сделать импорт проектов написанных ранее, выбрал проект qt на базе qmake, он сам нашел .pro файл и импортировал проект и вообщем мои старые проекты нормально собираются даже через kdevelop... попробую еще сам написать простенькое чтонить с нуля, посмотрю собереться или нет...
Спасибо сказали:
Sleek
Сообщения: 9

Re: KDevelop+Qt

Сообщение Sleek »

На всякий случай, вот список инклюдов после работы визарда кдевелоп:

Код: Выделить всё

#include "mytest.h"

#include <qimage.h>
#include <qpixmap.h>
#include <qtoolbar.h>
...


а версия qt установлена какя? если 4я, то include'ы должны выглядеть как #include <QImage> и т. д.

Вообще я на KDevelop забил, но способ интегрировать qt у меня следующий (может не самый простой и правильный, но зато работает в большинстве IDE):
делаем скрипт с командами

Код: Выделить всё

qmake -project
qmake
make

и прописываем путь к нему вместо make (в KDevelopp Параметры проекта, вкладка Параметры make )
Спасибо сказали:
Аватара пользователя
n37g0d
Сообщения: 65
ОС: debian5

Re: KDevelop+Qt

Сообщение n37g0d »

Sleek писал(а):
11.03.2008 22:45
а версия qt установлена какя? если 4я, то include'ы должны выглядеть как #include <QImage> и т. д.

да так и оказалось, визард генерит инклюды "не так" как надо для четверки, вот и тупило... а мои проги написаны уже аля include <QImage> и они откомпились без лишних вопросов...

з.ы. да поставил кдевелоп просто попробовать, вдруг понравится... так до этого только и пользовал

Код: Выделить всё

qmake -project
qmake
make
Спасибо сказали: