Hello - I know this *should* work, but I can't seem to figure it out. I have a QTreeView with a complex ItemDelegate that is made up of several widgets inside a frame. I want to insert some text(the name of a database field) into one of those widgets on a double-click in another TreeWidget ( a list of database fields in a docking window). I have done this:
connected the double-click signal from the docking window TreeWidget to the ItemDelegate:
connect( this->getFieldsList(), SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int) ), del, SLOT( insertText( QTreeWidgetItem *, int ) ) );
To copy to clipboard, switch view to plain text mode
where del is the item delegate. This works fine.
defined a slot in the item delegate called insertText as:
{
QString qualified_name
= item
->parent
()->text
( col
) +"."+ item
->text
( col
);
int cnt
= receivers
( SIGNAL(textToInsert
( const QString & ) ) );
emit textToInsert( qualified_name );
}
void RWDelegate::insertText( QTreeWidgetItem *item, int col )
{
QString qualified_name = item->parent()->text( col ) +"."+ item->text( col );
int cnt = receivers( SIGNAL(textToInsert( const QString & ) ) );
emit textToInsert( qualified_name );
}
To copy to clipboard, switch view to plain text mode
the number of receivers is always 0, by the way
defined a signal in the item delegate as:
signals:
void textToInsert
( const QString & qualified_name
);
signals:
void textToInsert( const QString & qualified_name );
To copy to clipboard, switch view to plain text mode
connected the specific widget that should receive the textToInsert signal in createEditor as:
RWFilterEdit *query_filter = new RWFilterEdit( query_open );
bool isconnect
= connect( this,
SIGNAL( textToInsert
( const QString &)), query_filter ,
SLOT( Inserter
( const QString &) ) );
RWFilterEdit *query_filter = new RWFilterEdit( query_open );
bool isconnect = connect( this, SIGNAL( textToInsert( const QString &)), query_filter , SLOT( Inserter( const QString &) ) );
To copy to clipboard, switch view to plain text mode
the variable isconnect returns true
defined a slot in the item delegate widget class (RWFilterEdit) as:
public slots:
void Inserter
( const QString & qualified_name
);
public slots:
void Inserter( const QString & qualified_name );
To copy to clipboard, switch view to plain text mode
I can see the signal get emitted when debugging... but it never hits a break point in the Inserter slot. I'm processing some other signals from other widgets - but they're Qt signals (eg. currentIndexChanged) and they work fine. What am I missing???
Oh.. also a follow on question -- I hope this isn't a silly one -- why does Intellisense show the QString class as type" static int RWDelegate::QString" in my idem delegate? Other Qt classes are shown as (example) "class QTreeView"? Just curious.
Bookmarks