Page 3 of 3 FirstFirst 123
Results 41 to 50 of 50

Thread: Program crashes

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

    Default Re: Program crashes

    the read->append(tmp in post #37 is for the MainWindow the problem is the read->append in Channel, it doesnt work ;/////

  2. #42
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program crashes

    What is "read" from post #37 and what is "read" from post (the one that doesn't work)? They point to different objects, yes?

    Naming your variables in such a vague way is probably not the best programming practice...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #43
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    #37 works, #25 doesnt :-((((
    #37 point to MainWindow, #25 points to Channel.

  4. #44
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program crashes

    Is English your primary language? Do you have problems understanding what I write? If I'm not clear enough, please say what needs clarification as so far you have misunderstood what I said a couple of times. I'm asking you what your "read" variables contain in both cases (MainWindow and Channel classes).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #45
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    because ur asking too many weird questions... whats it all about is:
    1. i made the channel class which inherits QWidget
    2. i open up a tab when basically the user requests to join a channel basically like this:
    Qt Code:
    1. tabs->addTab(new Channel(this, QString::fromLatin1(buffer), socket), QString::fromLatin1(buffer));
    To copy to clipboard, switch view to plain text mode 
    3. the "read QTextEdit is in both MainWindow and Channel, the one in the MainWindow is for reading server messages not reading channel messages, the one in Channel for reading the channel messages.
    4. theres no "4", i think ive explained it all.
    its all about a simple irc client, if u can help that would be appreciated.
    heres the headers of "Channel" & "MainWindow":
    mainwindow.h:
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QDialog>
    5.  
    6. #include "channel.h"
    7.  
    8. class QTabWidget;
    9. class QTcpSocket;
    10. class QLineEdit;
    11. class QLabel;
    12. class QTextEdit;
    13.  
    14. class MainWindow : public QDialog
    15. {
    16. Q_OBJECT
    17. public:
    18. explicit MainWindow(QWidget* parent = 0);
    19.  
    20. public slots:
    21. void Connect();
    22. void appendToWindow();
    23. void sendMessage();
    24. void displayError(QAbstractSocket::SocketError socketError);
    25.  
    26. private:
    27. QPushButton *done, *quit, *send;
    28. QLineEdit *write;
    29. QTcpSocket *socket;
    30. QTextEdit *read;
    31. QTabWidget* tabs;
    32. bool connected;
    33. };
    34. #endif
    To copy to clipboard, switch view to plain text mode 
    channel.h:
    Qt Code:
    1. #ifndef CHANNELS_H
    2. #define CHANNELS_H
    3.  
    4. #include <QWidget>
    5. #include <QTcpSocket>
    6.  
    7. class QLineEdit;
    8. class QTextEdit;
    9.  
    10. class Channel : public QWidget
    11. {
    12. Q_OBJECT
    13. public:
    14. Channel(QWidget* parent, const QString& name, QTcpSocket* socket);
    15. void printText(const QString& text);
    16.  
    17. public slots:
    18. void sendMessage();
    19.  
    20. private:
    21. QString chan;
    22. QLineEdit* write;
    23. QTextEdit* read;
    24. QTcpSocket* m_socket;
    25. };
    26. #endif
    To copy to clipboard, switch view to plain text mode 
    i hope u understand me now.

  6. #46
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program crashes

    Quote Originally Posted by Fallen_ View Post
    because ur asking too many weird questions...
    I'm not asking weird questions. I just have to practically extract each piece of answer out of you because you are not eagar to surrender any information willingly.

    Let's go back to the beginning...

    Please modify your methods so that they contain the following pieces of code:

    Qt Code:
    1. Channel::printText(const QString& text) {
    2. qDebug() << Q_FUNC_INFO << text;
    3. read->append(text);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::appendToWindow() {
    2. // ...
    3.  
    4. Channel* chan = new Channel(0, QString::fromStdString(channel), 0);
    5. chan->printText(QString::fromLatin1(tmp));
    6. qDebug() << Q_FUNC_INFO << tmp << QString::fromLocal8Bit(tmp);
    7. read->append(tmp);
    8.  
    9. // ...
    10. }
    To copy to clipboard, switch view to plain text mode 

    Please show us the output and the relevant pieces of sourcecode after the changes.

    Also, if you are using Qt Creator, please right click on your "read" variable from the "Channel" class, choose "Rename symbol under cursor" (or something like that) and enter "channelText". Do the same for MainWindow::read and rename it to "serverText". Then we won't be confusing the two variables anymore...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #47
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    Qt Code:
    1. void MainWindow::appendToWindow()8‘|ÿÿÿÿ8?|????
    2. 8‘|ÿÿÿÿ
    3. :wineasy1.se.quakenet.org 376 Fallen_ :End of /MOTD command.
    4.  
    5. void MainWindow::appendToWindow()8‘|ÿÿÿÿ8?|????
    6. 8‘|ÿÿÿÿ
    7. void MainWindow::appendToWindow()[03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    8. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    9.  
    10. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    11.  
    12. :wineasy1.se.quakenet.org 221 Fallen_ +i
    13.  
    14. void MainWindow::appendToWindow()[03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    15. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    16.  
    17. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    18.  
    19. :Fallen_!~Fallen_@41.199.113.40 MODE Fallen_ +i
    20.  
    21. void MainWindow::appendToWindow()[03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    22. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    23.  
    24. [03:07:13] Notice from: Message: on 2 ca 1(4) ft 20(20) tr
    To copy to clipboard, switch view to plain text mode 
    this is the output

  8. #48
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program crashes

    So there is no output from Channel::printText?

    By the way, is this:

    8‘|ÿÿÿÿ8?|????
    8‘|ÿÿÿÿ

    what you expected to print in the text edit (apart from the readable text, of course)?

    By the way, your "method" of recognizing the command is extremly error prone. Try passing it a "/JOIN #NOTICE" command and see for yourself. Your client will react on "NOTICE" and not on "JOIN". Also this method is prone to buffer overflows. I don't know why you insist on using this C-style API, you are just asking yourself for trouble there (i.e. try sending a really long (like, over 1000 characters long) notice).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #49
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    this text wont appear in the channel tab since u join after it has finished sending MOTD. wheres tbscope when u need him the most =_=

  10. #50
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Program crashes

    Quote Originally Posted by Fallen_ View Post
    this text wont appear in the channel tab since u join after it has finished sending MOTD.
    If by showing things irrelevant to the problem you wanted to discourage me from helping you then you have achieved your goal. 50 posts without progress is probably a record of this forum...

    tbscope is probably sleeping. Only I'm crazy enough to be sitting here at this hour.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. qstringlist array crashes program
    By chrisb123 in forum Newbie
    Replies: 4
    Last Post: 23rd October 2009, 16:03
  2. Program crashes on creating new dialog
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 12:52
  3. program crashes (QtTestRunner)
    By fmariusd in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 10:27
  4. Program crashes (SIGSEGV)
    By Voldemort in forum Qt Programming
    Replies: 47
    Last Post: 21st May 2007, 21:09
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 20: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.