Saturday, July 5th 2008, 2:30pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, May 2nd 2008, 8:02am

misidentified object

so ive not had too much experience with c++, perhaps only two semesters of college courses which often referenced/used it. ive been trying to learn some Qt, esp after seeing some neat videos of embedded WebKits.

I'm having trouble connecting a signal to a slot in a very simple case. However I suspect this is because I have not declared/defined my classes correctly. I'm posting here because I suspect its my shaky C++ basis rather than the Qt code.

Well here goes:

The following code returns a run time error:
"Object::connect: No such slot QWidget::timeOut()"

I'm trying to connect to MyWidget, not QWidget, but I don't see what is getting mixed up.

Thanks!

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <QApplication>
#include <QGraphicsScene>
#include <QGraphicsProxyWidget>
#include <QGraphicsView>
#include <QWebView>
#include <QTimer>
#include <stdio.h>
#include "attempt1.h"
#include <QWidget>



 class MyWidget : public QWidget
{
    public slots:
	void timeOut()
	{
	    printf("hi\n");
	    update();
	}

    public:
	MyWidget(QWidget *parent = 0)
	{
	    scene = new QGraphicsScene();
	    setFixedSize(300, 300);
	    scene->setBackgroundBrush(Qt::yellow);
	    webview = new QWebView(0);
	    webProxy = scene->addWidget(webview);
	    webProxy->scale(.7, .7);
	    webProxy->shear(0, -.25);
	    webProxy->rotate(45);
	    webview->load(QUrl("http://www.google.com/"));
	    webview->show();

	    timer = new QTimer(this);
	    connect(timer, SIGNAL(timeout()), this, SLOT(timeOut()) );
	    timer->start();
	}
	
	QGraphicsScene* getScene()
	{
	    return scene;
	}

    private:
	QGraphicsScene* scene;
	QGraphicsProxyWidget *webProxy;
	QWebView *webview;
	QTimer *timer;
};


  int main(int argc, char **argv)
     {
         QApplication app(argc, argv);
	 MyWidget widget;
         QGraphicsView view(widget.getScene());
         view.show();
         return app.exec();
     }
  • Go to the top of the page

SD_R3veNG

Beginner

Posts: 32

Location: Belgium

Occupation: student

2

Friday, May 2nd 2008, 2:15pm

add the Q_OBJECT-macro..

Does this resolve your problem?
*/ No comment /*
  • Go to the top of the page

3

Friday, May 2nd 2008, 6:46pm

You were correct -- I made an error regarding the Qt definitions. Thanks for the quick reply.

Sorry the post ended up in the wrong category, but thanks for help!
  • Go to the top of the page

Rate this thread