3

I'm developping a Qt GUI application.

My problem is that I use the console for another thread (it write his comunication in it), and the main problem is that when I create a QFileDialog (in order to select a script file), KDE is wrinting useless informations (for me at least).

Is there a way to remove all possibility from my QFileDialog to write anything into the consolethat ? Is there a trick to switch main output to another (useless) target ?

My code (but I don't think it's really gonna help you) :

void MyGUI::setPathWithFileExplorer()
{
  QFileDialog dlg;
  dlg.resize(320,240);
  QString fileName = dlg.getOpenFileName(this, tr("Open script file"), "~/", tr("Script Files (*.js)"));

  if(fileName != "")
    ui->editScriptPath->setText(fileName);
}

Output :

kded(21003) Mollet::KioSlaveNotifier::onDirectoryEntered: "trash:/" kded(21003) Mollet::KioSlaveNotifier::onDirectoryLeft: "trash:/" kded(21003) Mollet::KioSlaveNotifier::onDirectoryEntered: "file://[PATH TO MY USER FOLDER]" kded(21003) Mollet::KioSlaveNotifier::onDirectoryLeft: "file://[PATH TO MY USER FOLDER]" kded(21003) Mollet::KioSlaveNotifier::onDirectoryEntered: "file://[PATH TO MY USER FOLDER]" kfilemodule(21676) KSambaSharePrivate::testparmParamValue: We got some errors while running testparm "Load smb config files from /etc/samba/smb.conf Loaded services file OK. WARNING: The setting 'security=ads' should NOT be combined with the 'password server' parameter. (by default Samba will discover the correct DC to contact automatically). WARNING: You have some share names that are longer than 12 characters. These may not be accessible to some older clients. (Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.) " QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: Permission non accordée QFileSystemWatcher: failed to add paths: /var/lib/samba/usershares

MokaT
  • 1,416
  • 16
  • 37
  • 2
    What exactly does QFileDialog print to debug? – hank Jan 10 '14 at 13:24
  • Yeah, is it warning or regular messages? OT: `fileName != ""` should be `!fileName.isEmpty()`. You could work this around by writing into file rather than output, and "tail" that file in another console. – László Papp Jan 10 '14 at 13:26
  • @hank: what exactly do you mean by debug? I do not see the OP mentioning debug just yet. – László Papp Jan 10 '14 at 13:29
  • With whom is your other thread communicating? I'd rather use a separate pipe/socket etc. in a UI application, rather than stdout. – Frank Osterfeld Jan 10 '14 at 13:50
  • I believe if you use the release rather than the debug Qt libraries, the Qt chatter will go away. (You may have to manually tweak your settings in your project/makefile to link these in. Drop the "d" off the libraries.) – metal Jan 10 '14 at 14:06
  • @LaszloPapp I'll change the fileName statement, thanks, how can I do write into a file ? I still need the output of my other thread (comming from the same main program), is it possible to write into a file only GUI output ? – MokaT Jan 10 '14 at 14:10
  • @FrankOsterfeld My other thread is used to comunicate with an embedded linux system. It print sended and received message into my console. This is why I don't want the 'polution' of QFileDialog – MokaT Jan 10 '14 at 14:10
  • @hank I've edited my post with the non-wanted output – MokaT Jan 10 '14 at 14:11
  • 1
    That’s output from KDE, not from Qt. – Frank Osterfeld Jan 10 '14 at 14:12
  • 1
    @TimothéeBéhéty: your problem is actually _KDE_, not Qt. KDE is really spammy inherently; I always disliked it. I recommend to update the title accordingly as it is confusing right now. I would just write the log into a file - as it may be useful anyway -, and would monitor that in a separate console. You could even use the new logger in 5.2. – László Papp Jan 10 '14 at 14:12
  • @TimothéeBéhéty: run kdebugdialog and deselect all alternatively. – László Papp Jan 10 '14 at 14:25

1 Answers1

3

I would suggest using kdebugdialog and then Deselect All. Here you can see an inline screenshot on my machine.

enter image description here

Failing that, you could always use QFile to log your output into a dedicated file, and then monitor that in a separate prompt or application.

If you go down that way, you could even take a look at the logger functionality added in 5.2 if you happen to be able to use that version.

László Papp
  • 51,870
  • 39
  • 111
  • 135
  • It works thanks. For the logger part, I'm unfortunately using and have to use Qt 4.8.1. – MokaT Jan 10 '14 at 14:31
  • That will only fix the issue locally, so not a good solution if you want to deploy the program and the other thread uses stdout/stderr for critical functionality. But really, relying on them being clean is dangerous and should be avoided. – Frank Osterfeld Jan 10 '14 at 14:35
  • @FrankOsterfeld: we do not know the exact use case, hence see the text after the screenshot for an IMO reasonable fallback option if the kde setting does not suffice. – László Papp Jan 10 '14 at 14:40
  • I've totally unchecked all kdebugdialog. I'm not interested of whatever it is saying to me. – MokaT Jan 10 '14 at 14:48
  • @TimothéeBéhéty: yes, you can even use the `Disable all debug output option`. Note that there might be some kde software not respecting these settings, but it should be the rarity, hopefully. – László Papp Jan 10 '14 at 14:50