Results 1 to 10 of 10

Thread: Few newbie questions

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Few newbie questions

    Hi all. I've gotta few questions.
    ----------------------------------------------
    1. I have created a main window, complete menus and toolbars, all is good, but I want to make a dialog, which will be called when a user clicks a About button in my menu. Ok, so I have created new dialog, but I can't connect it to the actionAbout (beacuse I saved the dialog in other file). I mean that i can't connect it even if both files are opened in the same time. How can I connect it?
    ----------------------------------------------
    2. How to do it: If a user clicks a save button, program saves LineEdit contents in to a file which user select. And how to make more difficult actions?
    ----------------------------------------------
    3. Finally, how to build a program when everything is designed?

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Few newbie questions

    Quote Originally Posted by Salazaar View Post
    Hi all. I've gotta few questions.
    ----------------------------------------------
    1. I have created a main window, complete menus and toolbars, all is good, but I want to make a dialog, which will be called when a user clicks a About button in my menu. Ok, so I have created new dialog, but I can't connect it to the actionAbout (beacuse I saved the dialog in other file). I mean that i can't connect it even if both files are opened in the same time. How can I connect it?
    ----------------------------------------------
    2. How to do it: If a user clicks a save button, program saves LineEdit contents in to a file which user select. And how to make more difficult actions?
    ----------------------------------------------
    3. Finally, how to build a program when everything is designed?
    1)
    Qt Code:
    1. void MainWindow::slotAboutButton()
    2. {
    3. QDialog* dlg = new QDialog(this);
    4. dlg->show();
    5. }
    6. use this connect statement in your mainwindow
    7. connect( btnAction, SIGNAL( clicked() ), this, slotAboutButton() ));
    To copy to clipboard, switch view to plain text mode 
    2) Similar way connect clicked signal of save Button to some slot and use QTextStream to save data to a file.
    3) It depends what you are using (linux or windows). On windows you can create a vcproject using the pro file and load it. Then there is a build button to build the program.
    On linux either you can use kdevelop or just say
    Qt Code:
    1. qmake test.pro
    2. make
    To copy to clipboard, switch view to plain text mode 
    There are many ways to do so.. Please read qtAssistance about qmake you will get an idea about what to do.

    Thanks

  3. #3
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few newbie questions

    Hi. Thanks for your reply. I've gotta question about 2). Where do I have to type this code in qt designer?

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Few newbie questions

    Quote Originally Posted by Salazaar View Post
    3. Finally, how to build a program when everything is designed?
    Using a Component in Your Application

    Quote Originally Posted by Salazaar View Post
    2). Where do I have to type this code in qt designer?
    How can I add a custom slot in Qt4 Designer?
    J-P Nurmi

  5. #5
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few newbie questions

    Yeah, I can't, so how can I do 1) But to make aplications using qt designer I have to have correctly installed this damn qt, what a can't do since march...
    Last edited by Salazaar; 2nd May 2007 at 21:10. Reason: ...

  6. #6
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Few newbie questions

    Quote Originally Posted by Salazaar View Post
    Yeah, I can't, so how can I do 1) But to make aplications using qt designer I have to have correctly installed this damn qt, what a can't do since march...
    What do you mean you have to correctly install qt designer. Isnt it installed?? Tell us the process you followed and we can help you correct. Did you try getting the same output without using qt designer??

  7. #7
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Few newbie questions

    Quote Originally Posted by vermarajeev View Post
    Qt Code:
    1. void MainWindow::slotAboutButton()
    2. {
    3. QDialog* dlg = new QDialog(this);
    4. dlg->show();
    5. }
    6. use this connect statement in your mainwindow
    7. connect( btnAction, SIGNAL( clicked() ), this, slotAboutButton() ));
    To copy to clipboard, switch view to plain text mode 
    What will happen if the button is clisked several times... Do you see something wrong ?

    Better solution would be to create the dialog only if it is not created ? this cab be done by making the dlg a data member. in the constructor you can set it to 0.

    Qt Code:
    1. MainWindow::MainWindow(){
    2. // ....
    3. dlg = 0;
    4. }
    5. [...]
    6. void MainWindow::slotAboutButton()
    7. {
    8. if( dlg == 0 ) {
    9. dlg = new QDialog(this);
    10. }
    11. dlg->show();
    12. dlg->raise();
    13. dlg->activateWindow()
    14. }
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

  8. #8
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Few newbie questions

    That was just a sample to give an idea about how it can be solved.

    Anyway thanks for correction

    Or it can even be done in this way
    Qt Code:
    1. void MainWindow::slotAboutButton(){
    2. QDialog* dlg = new QDialog(this);
    3. dlg->show();
    4. //No need for qDialog so delete it immediately
    5. delete dlg;
    6. dlg = 0;
    7. }
    To copy to clipboard, switch view to plain text mode 

    If you want the instance of dlg later in your progrm then you have to create a member variable as Sunil suggested

    Thanks
    Last edited by vermarajeev; 3rd May 2007 at 07:43.

  9. #9
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Few newbie questions

    I would rather create it on Stack than on Heap
    And other thing is that show() is a non blocking code. you should use exec instead
    Last edited by sunil.thaha; 3rd May 2007 at 09:45.
    We can't solve problems by using the same kind of thinking we used when we created them

  10. #10
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Few newbie questions

    Ok, so I have:
    1) Downloaded Qt 4.2.3 Open Source installer
    2) Installed it to my Dev-C++ directory
    3) Added this template to my Dev-Cpp/Temaplates
    4) Added C:/Qt/4.2.3/lib library and C:/Qt/4.2.3/bin binary file to Dev-C++ by tools->compilator options->directories
    That's all. So what I am doing wrong?

Similar Threads

  1. Newbie - experiences with Qt
    By masoroso in forum General Discussion
    Replies: 1
    Last Post: 3rd May 2006, 14:44
  2. QT/Win 4.1.1 with VisualStudio2005 Newbie
    By skaiser in forum Installation and Deployment
    Replies: 9
    Last Post: 24th March 2006, 02:26
  3. 2 Questions about layouts
    By SkripT in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2006, 13:54
  4. Qt related questions and thoughts about getting job
    By AlexKiriukha in forum General Discussion
    Replies: 4
    Last Post: 26th January 2006, 12:25

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.