Seite 1 von 1

[gelöst] Warum immer dieser Fehler ??

Verfasst: 20. Juni 2007 23:38
von Treehouse
Hallo zusammen,

ich bin noch ganz frisch in der GUI Programmierung aber ich bin schon fleisig dabei fortschritte zu machen. Ich habe allerding ein kleines Problem bei dem ich nicht so recht weiter weiß ich hoffe ihr könnt mir da mal ein bisschen auf die Sprünge helfen.

Ich bekomme immer folgenden Fehler:

./Book
Object::connect: No such signal QListWidget::itemClicked(QListWidgetItem*item)
Object::connect: (sender name: 'buddyList')
Object::connect: (receiver name: 'setForm')


Hier mal der Code zum ganzen Dilemma:

main.cpp:

Code: Alles auswählen

#include <iostream>
#include "mainWindow.h"


using namespace std;


int main(int argc, char **argv){

  QApplication app(argc, argv);

  mainWindow book;

  book.show();


  return app.exec();




}
setForm.h

Code: Alles auswählen

/********************************************************************************
** Form generated from reading ui file 'setForm.ui'
**
** Created: Wed Jun 20 23:33:02 2007
**      by: Qt User Interface Compiler version 4.3.0
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
********************************************************************************/

#ifndef UI_SETFORM_H
#define UI_SETFORM_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QGroupBox>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>

class Ui_setForm
{
public:
    QPushButton *quitButton;
    QPushButton *addButton;
    QListWidget *buddyList;
    QGroupBox *groupBox;

    void setupUi(QWidget *setForm)
    {
    if (setForm->objectName().isEmpty())
        setForm->setObjectName(QString::fromUtf8("setForm"));
    QSize size(602, 547);
    size = size.expandedTo(setForm->minimumSizeHint());
    setForm->resize(size);
    quitButton = new QPushButton(setForm);
    quitButton->setObjectName(QString::fromUtf8("quitButton"));
    quitButton->setGeometry(QRect(230, 500, 75, 26));
    addButton = new QPushButton(setForm);
    addButton->setObjectName(QString::fromUtf8("addButton"));
    addButton->setGeometry(QRect(120, 500, 75, 26));
    buddyList = new QListWidget(setForm);
    buddyList->setObjectName(QString::fromUtf8("buddyList"));
    buddyList->setGeometry(QRect(330, 20, 251, 501));
    groupBox = new QGroupBox(setForm);
    groupBox->setObjectName(QString::fromUtf8("groupBox"));
    groupBox->setGeometry(QRect(320, 0, 271, 531));

    retranslateUi(setForm);
    QObject::connect(quitButton, SIGNAL(clicked()), setForm, SLOT(close()));

    QMetaObject::connectSlotsByName(setForm);
    } // setupUi

    void retranslateUi(QWidget *setForm)
    {
    setForm->setWindowTitle(QApplication::translate("setForm", "Phonebook", 0, QApplication::UnicodeUTF8));
    quitButton->setText(QApplication::translate("setForm", "&Quit", 0, QApplication::UnicodeUTF8));
    addButton->setText(QApplication::translate("setForm", "&Add", 0, QApplication::UnicodeUTF8));
    groupBox->setTitle(QApplication::translate("setForm", "Contacts", 0, QApplication::UnicodeUTF8));
    Q_UNUSED(setForm);
    } // retranslateUi

};

namespace Ui {
    class setForm: public Ui_setForm {};
} // namespace Ui

#endif // UI_SETFORM_H
mainWindow.cpp:

Code: Alles auswählen

#include "mainWindow.h"
#include <iostream>


using namespace std;

mainWindow::mainWindow(QWidget *parent):QWidget(parent){

    QListWidgetItem it;

  setupUi(this);
  fillList();
  //  trayIcon();
  connect(buddyList, SIGNAL(itemClicked(QListWidgetItem *item )), this, SLOT(message(QListWidgetItem*)));
}

void mainWindow::fillList(){

  QFile file("file.dat");
  QStringList str;
  file.open(QIODevice::ReadWrite);
  QTextStream stre( &file);
  QListWidgetItem item;
  
  do{
    str.append(stre.readLine());
  }while(!stre.atEnd());

  buddyList->addItems(str);
}


void mainWindow::trayIcon(){

  QSystemTrayIcon *tray = new QSystemTrayIcon;
  QString title("Hallo");
  QString mess("Da bin ich");

  tray->show();
  tray->showMessage( title, mess, QSystemTrayIcon::Information,  10000 );

}


void mainWindow::message(QListWidgetItem *item){

  
  QString in = buddyList->currentItem()->text();

  

}
mainWindow.h

Code: Alles auswählen

#ifndef _MAINWINDOW_
#define _MAINWINDOW_

#include "setForm.h"
#include <QListWidgetItem>
#include <QFile>
#include <QTextStream>
#include <QString>
#include <QStringList>
#include <QSystemTrayIcon>

using namespace std;

class mainWindow: public QWidget, private Ui::setForm{

  Q_OBJECT

    public:

  mainWindow(QWidget *parent = 0);
  void fillList();
  void trayIcon();
  
 private:

  public slots:

  void message(QListWidgetItem*);

};

#endif



Also es wäre super wenn mir jemand meinen Fehler sagen könnte ich suche schon seit Stunden danach aber ich komme nicht auf die Lösung. Bei dem kleinen Prog soll es sich später mal um ein Telefonbuch handeln aber ich Übe damit mehr als alles andere so richtig zum Finish komme ich damit noch lange nicht dafür habe ich noch viel zu viele offene Fragen.

Gruß

Treehouse

Verfasst: 21. Juni 2007 00:15
von Volker
beim connect Aufruf darf kein Variablenname angegeben werden sondern nur der Datentyp.

Code: Alles auswählen

  connect(buddyList, SIGNAL(itemClicked(QListWidgetItem*)),this, SLOT(message(QListWidgetItem*))); 
statt dem itemClicked(QListWidgetItem *item ) muss es also nur itemClicked(QListWidgetItem*) heißen.

Verfasst: 21. Juni 2007 10:21
von Treehouse
Ohhh mist wie doof ist der Fehler denn .............. naja danke erst mal ich hoffe das es dann so klappt werde das heute abend mal testen.

Gruß Treehouse

PS: Ich sezte das dann später auf gelöst sobald ich das ausprobiert habe.