Results 1 to 8 of 8

Thread: Problem calling a function of a class from another class.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem calling a function of a class from another class.

    Hi, when calling these functions (the highlighted ones (between [.b][./b])):
    Qt Code:
    1. #include "startup.h"
    2. #include <QtGui>
    3.  
    4. Startup::Startup(QWidget* parent)
    5. : QDialog(parent)
    6. {
    7. portLabel = new QLabel(tr("Port:"));
    8. chanLabel = new QLabel(tr("Channel:"));
    9. nickLabel = new QLabel(tr("Nick:"));
    10. serverLabel = new QLabel(tr("Server:"));
    11.  
    12. portLine = new QLineEdit;
    13. chanLine = new QLineEdit;
    14. nickLine = new QLineEdit;
    15. serverLine = new QLineEdit;
    16.  
    17. done = new QPushButton(tr("Finished"));
    18. quit = new QPushButton(tr("Close"));
    19.  
    20. mainW = new MainWindow;
    21.  
    22. connect(done, SIGNAL(clicked()), this, SLOT(showMainWindow()));
    23. connect(quit, SIGNAL(clicked()), this, SLOT(close()));
    24.  
    25. v->addWidget(serverLabel);
    26. v->addWidget(serverLine);
    27. v->addWidget(portLabel);
    28. v->addWidget(portLine);
    29. v->addWidget(chanLabel);
    30. v->addWidget(chanLine);
    31. v->addWidget(nickLabel);
    32. v->addWidget(nickLine);
    33. v->addWidget(done);
    34. v->addWidget(quit);
    35. setLayout(v);
    36. resize(100, 80);
    37. setWindowTitle(tr("Startup Window"));
    38. }
    39.  
    40. void Startup::showMainWindow()
    41. {
    42. mainW->show();
    43. }
    44.  
    45. [b]QString Startup::getServer() {
    46. return serverLine->text();
    47. }
    48.  
    49. QString Startup::getNick() {
    50. return nickLine->text();
    51. }
    52.  
    53. QString Startup::getChannel() {
    54. return chanLine->text();
    55. }
    56.  
    57. QString Startup::getPort() {
    58. return portLine->text();
    59. }[/b]
    To copy to clipboard, switch view to plain text mode 
    they return either "" or 0
    what am i doing wrong?
    Last edited by Fallen_; 2nd September 2010 at 19:00.

Similar Threads

  1. class calling other class functions?
    By Hardstyle in forum Newbie
    Replies: 4
    Last Post: 2nd June 2010, 02:38
  2. QtConncurrent - calling function within the class
    By jacek_ in forum Qt Programming
    Replies: 5
    Last Post: 28th October 2009, 17:37
  3. Replies: 1
    Last Post: 30th March 2009, 16:07
  4. Replies: 3
    Last Post: 16th May 2007, 11:07
  5. Problems calling C function in C++/Qt class
    By Rayven in forum General Programming
    Replies: 2
    Last Post: 2nd June 2006, 21:32

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.