Results 1 to 2 of 2

Thread: Issue using connect, what am I missing?

  1. #1
    Join Date
    Oct 2009
    Posts
    47
    Thanks
    10

    Question Issue using connect, what am I missing?

    hi guys,

    I'm doing a simple signal/slot connection and I'm not sure why I keep getting this message:
    C:/Users/Cory/Desktop/Dev/Web/webwidget.cpp:18: error: expected constructor, destructor, or type conversion before '(' token

    I get this on both the connections here:
    Qt Code:
    1. connect(ui->webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    2. connect(ui->locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));
    To copy to clipboard, switch view to plain text mode 


    Here is the full code:

    Qt Code:
    1. //webwidget.cpp
    2. #include "webwidget.h"
    3. #include "ui_webwidget.h"
    4.  
    5. WebWidget::WebWidget(QWidget *parent) :
    6. QWidget(parent),
    7. ui(new Ui::WebWidget)
    8. {
    9. ui->setupUi(this);
    10. }
    11.  
    12.  
    13. WebWidget::~WebWidget()
    14. {
    15. delete ui;
    16. }
    17.  
    18.  
    19. connect(ui->webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    20. connect(ui->locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation()));
    21.  
    22.  
    23.  
    24.  
    25. void WebWidget::adjustLocation()
    26. {
    27. ui->locationEdit->setText(ui->webView->url().toString());
    28.  
    29. }
    30.  
    31. void WebWidget::changeLocation()
    32. {
    33. QUrl url = QUrl(ui->locationEdit->text());
    34. ui->webView->load(url);
    35. ui->webView->setFocus();
    36. }
    37.  
    38.  
    39. void WebWidget::changeEvent(QEvent *e)
    40. {
    41. QWidget::changeEvent(e);
    42. switch (e->type()) {
    43. case QEvent::LanguageChange:
    44. ui->retranslateUi(this);
    45. break;
    46. default:
    47. break;
    48. }
    49. }
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //webwidget.h
    2. #ifndef WEBWIDGET_H
    3. #define WEBWIDGET_H
    4.  
    5. #include <QWidget>
    6. class QWebView;
    7.  
    8. namespace Ui {
    9. class WebWidget;
    10. }
    11.  
    12. class WebWidget : public QWidget {
    13. Q_OBJECT
    14. public:
    15. WebWidget(QWidget *parent = 0);
    16. ~WebWidget();
    17.  
    18. protected:
    19. void changeEvent(QEvent *e);
    20. void adjustLocation();
    21. void changeLocation();
    22.  
    23. private:
    24. Ui::WebWidget *ui;
    25. };
    26.  
    27. #endif // WEBWIDGET_H
    To copy to clipboard, switch view to plain text mode 


    I'm using qtcreator thats why you see me doing ui-> to reference the controls.


    Any help would be great.


    Thanks.

  2. #2
    Join Date
    Oct 2009
    Posts
    47
    Thanks
    10

    Default Re: Issue using connect, what am I missing?

    fixed it. I had to move the connects to the constructor and add slots to the funcitons.

Similar Threads

  1. Missing tileVertically()
    By zarkzervo in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2009, 07:01
  2. qt signal/slot auto-connect issue
    By parnedo in forum Qt Programming
    Replies: 9
    Last Post: 16th July 2009, 12:55
  3. Replies: 4
    Last Post: 10th November 2006, 15:38
  4. libQtGui_debug.so.4 missing
    By fwohlfert in forum Installation and Deployment
    Replies: 2
    Last Post: 5th October 2006, 19:07
  5. Missing slots
    By Mariane in forum Newbie
    Replies: 1
    Last Post: 5th February 2006, 01:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.