Page 1 of 3 123 LastLast
Results 1 to 20 of 47

Thread: kdialog and klocate problems

  1. #1
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default kdialog and klocate problems

    Hi to everyone,
    I'm doing a gui using Qt3 for a program made by other guy. I made it using QtDesginer and I get .ui file. Then using uic I created the headder and .cpp files. Now I'm using Kdevelop as IDE.
    I put all the files in a folder and did like this in command promp:

    qmake -project
    qmake testgui.pro
    make

    and get this error:

    g++ -c -pipe -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o gui_bt.o gui_bt.cpp
    gui_bt.cpp:10:21: error: kdialog.h: No existe el fichero o directorio ( Doesn't exist file or directory )
    gui_bt.cpp:11:21: error: klocale.h: No existe el fichero ó directorio ( Doesn't exist file or directory )
    gui_bt.cpp:106:22: error: gui_bt.moc: No existe el fichero ó directorio ( Doesn't exist file or directory )
    gui_bt.cpp: In member function ‘virtual void GUI_BT::languageChange()’:
    gui_bt.cpp:77: error: ‘tr2i18n’ was not declared in this scope
    make: *** [gui_bt.o] Error 1

    I have to say that one small program like the Hello World is working perfectly doing the same steps.
    Thanks for all.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    You are using KDE widgets (which are based on Qt) and the include path is not set for them.
    If you are using the KWidgets in purpose, then I guess you know that you make your app dependent of KDE - and it will not run where you can't link to kde.
    If you are not doing this on pupopose, use the QWidgets (without 'K' at the beginning).
    This will both eliminate your error (provided that you are including the problem q - header files) and make it cross platform.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    Thank you for your answer, and sorry for this stupid error
    I've been trying what you said and now i get this error:

    g++ -c -pipe -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o gui_bt.o gui_bt.cpp
    gui_bt.cpp:14:22: error: gui_bt.moc: No existe el fichero ó directorio ( )
    gui_bt.cpp: In member function ‘virtual void GUI_BT::languageChange()’:
    gui_bt.cpp:80: error: ‘tr2i18n’ was not declared in this scope
    make: *** [gui_bt.o] Error 1

    I can guess that I don't have gui_bt.moc.
    As I said I did the GUI using QtDesigner and the instruction uic, so, why I have this "tr2i18n" error if it's something that I just put in the GUI?? They are just names for the buttons. Here is the code for the function, maybe it can help:

    void GUI_BT::languageChange()
    {
    setCaption( tr2i18n( "BT scanning program" ) );
    Menu->setTitle( tr2i18n( "MENU" ) );
    b_scan->setText( tr2i18n( "Scan" ) );
    b_save->setText( tr2i18n( "Scan and Save" ) );
    b_save->setAccel( QKeySequence( QString::null ) );
    b_redfang->setText( tr2i18n( "RedFang" ) );
    b_exit->setText( tr2i18n( "Exit" ) );
    }

    Thanks again for your answer.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    The function tr2i18n() is a KDE function.
    Are you sure you are not using KDE Widgets (available in Designer) on your Dialog?

    After this is sortes out, we can deal with the uic problem.

    Hmm. I am not sure I fully understand the stucture of your project.
    Could you explain it in a bit more detail?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    ok, yes, maybe is better if I explain everything better.
    I have to do a GUI for a program made by other guy. The original program is made using C language.
    I was thinking about how to do it using C++ and after some research I decided to do it using Qt libraries because I'm in kubuntu. For the same reason I'm using Kdevelop as IDE.
    First I did the GUI with QtDesigner and get the .ui file. Using uic I get both the .h and the .cpp files. And then I went to KDevelop.
    Using KDevelop I did 3 files more: another .h and .cpp and also a main.cpp. I did this following one book.
    So, finally I have 5 files: gui_bt.h, gui_bt.cpp, gui.h, gui.cpp and main.cpp.
    Probably, as you said, when I was creating the GUI with QtDesigner I used KDE Widgets without knowing it. The problem is now how I have to compile the project and how I have to run it if I have all this mistakes, mixing QWidgets and KWidgets.....
    The only thing I'm doing now is trying to compile the project and run it. Just the GUI. I didn't do all the program, cause I have to match the program with my GUI yet. I put the bottoms I need for the menu, but the functions are not implemented yet, I just have the functions empty.
    I know that I don't know anything about how to use this libraies and the programs, that's why I would like to say to you thanks a lot for your help.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    Why are you using Qt3 and not Qt then?

    It will be much easier if you start all over, than for us to help you "patch -up" your project.
    You can do all you did in a much simpler way:
    Open KDevelop.
    Project->new Project
    Select QMake Project with a "Hello World" Template.
    In the make manager right click on the project, and "run qmake".
    Then build.
    If your project compiled then:
    To add new source and hader files, just right click "headers" or "sources" in the project manager on the right, and choose "add new".
    The ui you can add the same way, just choose "add existing".

    Post again if you have problems.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    Hi high_flyer,
    thanks a lot for your help. I did my project again from the beginning and everything is fine at the moment. It works and I could compile it without any problem.
    As you said, I did it wrong the first time because I was mixing KWidgets and QWidgets. Now i did It taking care about that and everything worked without problems.
    But now I have a problem with the actions of the menu.
    In the GUI there is a menu, 4 bottoms, each one is doing one actions, but I want the actions, all the results of that actions, appear in the GUI, in one on the areas that I create for that. Now, all the results are appearing in the terminal, not in the GUI. These areas are QTextEdit, but I don't know if there is another element to put instead of textEdit to do it, to do that the results appear in this area. Or maybe I missed some instruction....
    Thanks a lot again.

  8. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    all the results of that actions, appear in the GUI,
    Please understand that we have no knowledge of what you are doing.
    What are the "results" and what did you do to have them on the GUI?
    As far as I understand, your GUI communicates with a console application - is that correct?
    Does the infomation flow from the non GUI application to your GUI application work ok?
    Could you explain how you did that?

    Relevant code segements with explanations could help.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  9. #9
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    Sorry again for my really bad explanation. I'm not used to post in a forum like this one.
    Let's try to do it better:
    I had one program made in C language by another guy. All the results of that program appear in the terminal console. Also the program creates 3 files with the information. Now, I created the GUI and directly put the code of the original program in the menu, in each function on each button without changing anything. So, the program is working perfectly because when I press the buttons of the GUI they do what they has to do, but the results are still appearing in the terminal console, like before, not in the TextEdit that I put in the GUI.
    I know that is because there is no connection between both, my textEdit and the code of the original program because I did nothing, I just put the original code in each function of each button of the GUI. The code of the first function for example is like this:

    Button Scan

    void BTScanning::scan()
    {
    system("hcitool scan");
    }

    This function scans an area looking for some bluetooth devices that are connected, and the result of this function, once I press the button of the menu in the GUI appears in the terminal console, not in the textEdit area of the GUI.
    How can I do this? how can I "put" what appears in the terminal in that area of the GUI? How can I connect both?
    Thanks a lot again for your help.

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    Ok, now I see.
    Well, basically what you want is to read the output from the console, and diplay it in your gui -if I undertood you correctly.
    I see you are using the system() function, in Qt you will have to use the QProcess class to be able to tap to the stdio.
    Read the docs about it, and ask again when you get stuck.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    I've been reading the doc. for the QProcess class and I've been trying different things.
    Now I have like this in my .cpp file:

    first the include for the class
    Qt Code:
    1. #include <qprocess.h>
    2.  
    3. then the place where I want that the results appear:
    4. te_results = new QTextEdit( this, "te_results" );
    5. te_results->setGeometry( QRect( 250, 180, 341, 281 ) );
    6.  
    7. then the connection with the function scan():
    8. connect( pb_scan, SIGNAL( clicked() ), this, SLOT( scan() ) );
    9. pb_scan is the name of the button
    10.  
    11. and finally the function scan():
    12. void BTScanning::scan()
    13. {
    14. QProcess *process = new QProcess(this);
    15. QByteArray exit;
    16.  
    17. process->addArgument("hcitool scan");
    18.  
    19. exit->readAllStadardOutput();
    20.  
    21. process->start();
    22. }
    To copy to clipboard, switch view to plain text mode 

    But It appears one error like this when I'm trying to compile the project:
    btscanning.cpp: In member function ‘virtual void BTScanning::scan()’:
    btscanning.cpp:90: error: base operand of ‘->’ has non-pointer type ‘QByteArray’

    I tried a lot of different things:
    exit = process->start("hcitool scan");
    connect(process, SIGNAL((hcitool scan)), this, SLOT("te_results"));

    but nothings works...can you please help me. What I'm doing wrong? Thank you.
    Last edited by high_flyer; 4th May 2007 at 15:12. Reason: missing [code] tags

  12. #12
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    btscanning.cpp:90: error: base operand of ‘->’ has non-pointer type ‘QByteArray’
    That is because 'exit' is not a pointer, you should have use '.' and not '->'.
    But look you used it wrong as well.
    You should do something like:
    Qt Code:
    1. void BTScanning::scan()
    2. {
    3. QProcess *process = new QProcess(this);
    4. QByteArray exit;
    5. process->addArgument("hcitool scan");
    6. process->start()
    7. if (!process->waitForStarted())
    8. {
    9. //some error notification
    10. return;
    11. }
    12. process->waitForReadyRead();
    13. exit = process->readAll();
    14. //now you have your data in 'exit' - you can put it in a string and on to a textedit
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  13. #13
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    Hi,
    now I know what I was doing wrong. I was looking for the functions in the page that you gave to me:
    http://doc.trolltech.com/4.2/qprocess.html

    but the problem is that I'm not using Qt4, I'm using Qt3 so the page where I have to look for the functions is:
    http://doc.trolltech.com/4.0/q3process.html

    At the beginning I did the function as you put in the previous post and It appears this error:
    btscanning.cpp:91: error: ‘class QProcess’ has no member named ‘waitForStarted’
    btscanning.cpp:97: error: ‘class QProcess’ has no member named ‘waitForReadyRead’
    btscanning.cpp:99: error: ‘class QProcess’ has no member named ‘readAll’

    after that, I was looking through Trooltech page and I found the page that I put before.
    I know it was a stupid mistake but I'm trying to do this project for a long time and I'm starting to be really frustrated.
    I want to ask you about your opinion. Do you thing that I have to continue with Qt3 or I have to change to Qt4?
    Now that I nearly finish the project I'm a little bit scared of changing anything but If it will be better for me I can install Qt4 instead of Qt3.
    Thanks a lot.

  14. #14
    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: kdialog and klocate problems

    Quote Originally Posted by parsito View Post
    Do you thing that I have to continue with Qt3 or I have to change to Qt4?
    You can continue with Qt3 but you can also switch to Qt4.
    Now that I nearly finish the project I'm a little bit scared of changing anything but If it will be better for me I can install Qt4 instead of Qt3.
    There is a porting tool (qt3to4) that comes with Qt4 which does some basic translation from Qt3 to Qt4 code so porting should take no more than an hour, but you don't need to switch to Qt4 if the only problem is QProcess. Instead of doing it the synchronous way (waitForStarted(), etc.) connect a slot to processExited() or readyReadStdout() signal and redirect the output to your GUI widget.

  15. #15
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    Hi again,
    how can I convert one ByeteArray into a String to put it in the textEdit widget of the GUI? I'm trying to do like this:

    Qt Code:
    1. QProcess *process = new QProcess(this);
    2. QString res;
    3.  
    4. process->addArgument("hcitool scan");
    5. process->start();
    6.  
    7. exit = process->readStdout();
    8. //Here convert the bytearray "exit" into the string "res"
    9. te_results->insertParagraph(res,-1);
    To copy to clipboard, switch view to plain text mode 

    Am I doing it wrong? I'm doing it like this because I found the insertPragraph and is the only way that I see to make the results appear in the textEdit widget of the gui.
    Last edited by wysota; 8th May 2007 at 13:14. Reason: missing [code] tags

  16. #16
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: kdialog and klocate problems

    just do:
    Qt Code:
    1. te_results->insertParagraph(QString(exit),-1);
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 8th May 2007 at 13:14. Reason: missing [code] tags
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  17. #17
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    I did what you said, but nothing appear in the widget. The program compiles without problems so I can guess that I have the output in variable exit, but nothing appear in the widget te_results of the gui.

  18. #18
    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: kdialog and klocate problems

    Did you read my note about asynchronousness of the whole operation? Because lines 6-8 of your last code snippet suggest you didn't.

  19. #19
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: kdialog and klocate problems

    I'm sorry wysota, but I don't know how to asynchronize the whole operation.
    I tried doing something like this:

    BTScanning::BTScanning( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
    {

    QProcess *process = new QProcess(this);

    te_results = new QTextEdit( this, "te_results" );
    te_results->setGeometry( QRect( 250, 180, 341, 281 ) );

    ..........
    /*here the connection between the process and the widget*/
    connect( process, SIGNAL( readyReadStdout() ), te_results, SLOT( scan() ) );
    }

    and now the function scan():

    void BTScanning::scan()
    {
    QProcess *process = new QProcess(this);
    QByteArray exit;

    process->addArgument("hcitool scan");
    exit = process->readStdout();
    te_results->insertParagraph(QString(exit),-1);
    }

    I compile it without problems and the result is:

    QObject::connect: No such slot QTextEdit::scan()
    QObject::connect: (sender name: 'unnamed')
    QObject::connect: (receiver name: 'te_results')

    and when I press the Scan button, nothing appear anywhere.
    Can you please tell me what I'm doing wrong or how I have to do It? thank you very much.

  20. #20
    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: kdialog and klocate problems

    You could start by reading QProcess docs. There even is a snippet of code there that does what you're trying to achieve.

    I completely don't understand why you're creating a new QProcess object in scan() Where do you start the process anyway?

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.