Code Completion in UI classes
G'day All,
Is there some trick to having Creator (1.1 on Linux, Qt 4.5.1) do code completion for Designer UI? Currently I get no useful completion after entering "m_ui->" with code straight from the Creator/Designer wizard (example below). I'm fairly sure this has worked in the past.
Cheers,
Chris
Code:
#ifndef ALARMVIEW_H
#define ALARMVIEW_H
#include <QtGui/QWidget>
namespace Ui {
class AlarmView;
}
Q_OBJECT
Q_DISABLE_COPY(AlarmView)
public:
explicit AlarmView
(QWidget *parent
= 0);
virtual ~AlarmView();
protected:
virtual void changeEvent
(QEvent *e
);
private:
Ui::AlarmView *m_ui;
};
#endif // ALARMVIEW_H
Code:
#include "alarmview.h"
#include "ui_alarmview.h"
AlarmView
::AlarmView(QWidget *parent
) : m_ui(new Ui::AlarmView)
{
m_ui->setupUi(this);
m_ui-> // Completion fails here and only offers the class AlarmView and not the widgets
}
AlarmView::~AlarmView()
{
delete m_ui;
}
void AlarmView
::changeEvent(QEvent *e
) {
switch (e->type()) {
m_ui->retranslateUi(this);
break;
default:
break;
}
}
Re: Code Completion in UI classes
Try to compile it, and then you should have the completion features.
Re: Code Completion in UI classes
Thanks.
It was compiled on Gentoo and, for the most part, the completion works. Just the circumstances described above seem to break it. I've just done a quick rebuild to make sure that there were no broken deps. No change.
Is there a cache of information that might be corrupt or need rebuilding?
Re: Code Completion in UI classes
Code:
#include "ui_alarmview.h"
This file is auto generated from your .ui file. QtCreator doesn't have the current state of the file until it's compiled. So if you need autocompletion and make a change in the ui, you need to build again before you can use it.
Re: Code Completion in UI classes
Thanks.
I've built the example code (and lots of other examples) many times, no change :(
It is not that it is not completing recent changes in the UI: it's not completing anything in the UI. The only thing in the completion drop-down is class "AlarmView" (from the Ui namespace) despite there being a QPushButton and QTableWidget in the UI.
I have a separate build directory that ends up containing the ui_*.h files and other intermediates. Perhaps that is causing an issue. I'll do a quick experiment with everything in one directory.
Re: Code Completion in UI classes
WOOHOO! It works if all is in one directory, but not if split.
My pro file looks like:
Code:
# -------------------------------------------------
# Project created by QtCreator 2009-03-22T08:27:36
# -------------------------------------------------
QT += sql \
svg
CONFIG += qt \
debug \
warn_on
TARGET = project
TEMPLATE = app
MOC_DIR = build
OBJECTS_DIR = build
RCC_DIR = build
UI_DIR = build
INCLUDEPATH += src
VPATH = src \
res
HEADERS +=alarmview.h ...
FORMS += alarmview.ui ...
SOURCES += alarmview.cpp ...
RESOURCES += project.qrc
Is there something I should tweak here? I've tried adding the build directory to INCLUDEPATH and VPATH: no dice.