[solved] QAbstractItemView::rowsInserted() seems to have a problem...
-
I try to use it for a QTreeView (i use also a QAbstractItemView::dataChanged() who works fine...), nut i have some errors point on my .h file at declaration time:
errors list on this declarration line:
stray '/342' in program
stray '/200' in program
stray '/213' in programpart of classeurs_treeview.h code:
@
class Classeurs_treeView : public QTreeView
{
Q_OBJECT
....protected slots:
void mouseReleaseEvent ( QMouseEvent * event );
void dataChanged (const QModelIndex &topLeft,
const QModelIndex &bottomRight,
const QVector<int> &roles = QVector<int> ());
void rowsInserted(const QModelIndex &parent, // here is the error... (i just follow the doc)
int start, int end);
...
@part of my defined classeurs_treeview.cpp file
@
void Classeurs_treeView::rowsInserted(const QModelIndex &parent,
int start, int end) {
emit add_classeur(parent, start, end);
}
@the signal is catch by a inherited edit_project class, who inherit a new_project QDialog class
the new_project class not catch the signal and no have the slot declared, the slot is only in the edit_project class...the edit_project.cpp part of declared signal inside his constructor:
@
edit_project::edit_project(QWidget *parent, const int &id_project) {
user->initdb();
Project.id = id_project;
populate_entries();
ui_new_project->pushButton_add_comment_dir->setText("Editer le comentaire");
QObject::connect(ui_new_project->treeView_classeur,
SIGNAL(add_classeur(QModelIndex, int, int)),
this,
SLOT(on_treeView_classeur_add_classeur(const QModelIndex &parent,
int start, int end)));
}
@the edit_project.ccp part where the slot is define:
@void edit_project::on_treeView_classeur_add_classeur(const QModelIndex &parent,
int start, int end) {
for (int i(start); i <= end; i++) {
int id_tree = classeurs_model->index(i, 2, parent).data().toInt();
int id_tree_parent = classeurs_model->index(i, 3, parent).data().toInt();
QString nom = classeurs_model->index(i, 0, parent).data().toString();
QString comment = classeurs_model->index(i, 1, parent).data().toString();
QList<QVariant> datas;
datas << id_tree_parent << nom << comment;
Modified.classeurs_add.insert(id_tree, datas);
}
}
@the edit_project.h part of file where slot is declared:
@protected slots:
virtual void on_pushButton_OK_clicked() override ;
virtual void on_treeView_classeur_change_data(const QModelIndex &topLeft,
const QModelIndex &bottomRight,
const QVector<int> &roles) override;
virtual void on_treeView_classeur_delete_classeur(QModelIndexList list_indexs) override;
void on_treeView_classeur_add_classeur(const QModelIndex &parent,
int start, int end);
@i don't know..; maybe the error come from the fact that this slot is not declared inisde the new_project files/class. Maybe i need to catch the signal here and override the slot function ?
Someone has an idea ? -
you probably have some 'hidden' Unicode characters somewhere in your source files. Make sure they are ASCII only (except in string literals of course).
-
I guess you copy/pasted from the docs. Unfortunately, there are some unicode characters in there that don't go down nicely with compilers. That is unfortunate, but it does mean that the savest way is to just type your code yourself instead of using copy/paste.
-
that's right, this was exactly the problem.
thanks raven-workx and Andre
i do this post solved