Results 1 to 20 of 50

Thread: Program crashes

Hybrid 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 Re: Program crashes

    man i already made it to get the text, now when i do something like this:
    Qt Code:
    1. tabs->addTab(new Channel(this, QString(buffer), socket, ""), QString(buffer));
    To copy to clipboard, switch view to plain text mode 
    it works but i need it to append a text in the text edit of the channel, when i call printText (from the channel class) from another function it doesnt do anything:
    Qt Code:
    1. Channel *chan = new Channel(this, channel.c_str(), socket, tmp);
    2. chan->printText(tmp);
    To copy to clipboard, switch view to plain text mode 
    any ideas?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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
    man i already made it to get the text,
    I'm aware of it, the point is you are doing it with a C api that is cumbersome and error prone.

    it works but i need it to append a text in the text edit of the channel, when i call printText (from the channel class) from another function it doesnt do anything
    I have no idea what you mean. What is printText(), what other function and what was it supposed to do?
    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. #3
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    its to append a text in the "read" text edit

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Program crashes

    If you have still problems with the crash, put your code into a zip file and attach it to your post and I'll see what the problem is.

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

    Default Re: Program crashes

    Quote Originally Posted by wysota View Post
    I'm aware of it, the point is you are doing it with a C api that is cumbersome and error prone.


    I have no idea what you mean. What is printText(), what other function and what was it supposed to do?
    Well, the printText is a function in the "Channel" class when calling it from the "MainWindow" class it doesnt print text in the "read" textEdit, heres what printText supposed to do:
    Qt Code:
    1. void Channel::printText(const QString& text)
    2. {
    3. read->append(text);
    4. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Program crashes

    And how do you call it from MainWindow?
    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. #7
    Join Date
    Aug 2010
    Posts
    58
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Program crashes

    Qt Code:
    1. Channel* chan = new Channel(this, channel.c_str(), socket);
    2. chan->printText(tmp);
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Program crashes

    I guess that's because you create that C-style string pointer, if you want to create a QString from a std::string don't use the .c_str() method, use the static member function of QString fromStdString() (this create a copy of the string)

    It has been said: it's better if you use QString instead std::string (and C-style strings)

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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
    Qt Code:
    1. Channel* chan = new Channel(this, channel.c_str(), socket);
    2. chan->printText(tmp);
    To copy to clipboard, switch view to plain text mode 
    And the program runs but the text is not printed? What is the content of "tmp" at this moment?
    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.


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

    Default Re: Program crashes

    Quote Originally Posted by wysota View Post
    And the program runs but the text is not printed? What is the content of "tmp" at this moment?
    tmp is a char array with the received messages from the socket and ye it doesnt print the text.
    Quote Originally Posted by Zlatomir View Post
    I guess that's because you create that C-style string pointer, if you want to create a QString from a std::string don't use the .c_str() method, use the static member function of QString fromStdString() (this create a copy of the string)

    It has been said: it's better if you use QString instead std::string (and C-style strings)
    nope still doesnt work
    Last edited by Fallen_; 18th September 2010 at 21:56.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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
    tmp is a char array with the received messages from the socket and ye it doesnt print the text.
    I'm asking what it contains - literally. Please print it to your console, don't assume you know what's in there.
    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.


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

    Default Re: Program crashes

    Quote Originally Posted by wysota View Post
    I'm asking what it contains - literally. Please print it to your console, don't assume you know what's in there.
    thats what written in there:
    Qt Code:
    1. :stockholm.se.quakenet.org 366 Fallen_ #Fallen :End of /NAMES list.
    2.  
    3. [00:45:51] Fallen_ has joined #Fallen
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Program crashes

    And how did you print that to the console?
    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.


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

    Default Re: Program crashes

    using qDebug()?

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

    Default Re: Program crashes

    Show us the statement please. With a couple of surrounding lines.
    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, 15:03
  2. Program crashes on creating new dialog
    By eekhoorn12 in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 11:52
  3. program crashes (QtTestRunner)
    By fmariusd in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2008, 09:27
  4. Program crashes (SIGSEGV)
    By Voldemort in forum Qt Programming
    Replies: 47
    Last Post: 21st May 2007, 20:09
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 19: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
  •  
Qt is a trademark of The Qt Company.