
Originally Posted by
jp
OK then, if update is not updating and unless Qt is capable of faking events, Qt promises to be a fairly unwieldy scripting language!
No offense, but the problem is not at all within Qt. The problem lies in your code structure. Let's make this clear. How do you expect the list box to change it's contents after calling update()? It will just redraw earlierly inserted items. You need to pass the current dir from the line edit to the list box and change the contents.
To make this work, your code should look more like this:
{
setDir(item->text());
}
void CListBox::setDir(const QString& dir)
{
...
for (...)
insertItem(...)
...
emit dirChanged(dir);
}
void CLineEdit::onReturnPressed()
{
emit dirChanged(text());
}
QObject::connect(&lbox,
SIGNAL(dirChanged
(const QString
&)),
&ledit,
SLOT(setText
(const QString
&)));
QObject::connect(&ledit,
SIGNAL(dirChanged
(const QString
&)),
&lbox,
SLOT(setDir
(const QString
&)));
void CListBox::onActivation(QListWidgetItem *item)
{
setDir(item->text());
}
void CListBox::setDir(const QString& dir)
{
QFileInfo fiche(dir);
...
for (...)
insertItem(...)
...
emit dirChanged(dir);
}
void CLineEdit::onReturnPressed()
{
emit dirChanged(text());
}
QObject::connect(&lbox, SIGNAL(dirChanged(const QString&)), &ledit, SLOT(setText(const QString&)));
QObject::connect(&ledit, SIGNAL(dirChanged(const QString&)), &lbox, SLOT(setDir(const QString&)));
To copy to clipboard, switch view to plain text mode
Bookmarks