Results 1 to 20 of 41

Thread: closing a dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Header looks OK. The only thing I do not like is a lowercase class name because usually the first letter in the classname is uppercase.

    Regarding the dialog: Create the constructor in the constructor, save the pointer in a member variable and then only call show on it in your method.
    It's nice to be important but it's more important to be nice.

  2. #2
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    Quote Originally Posted by axeljaeger View Post
    Regarding the dialog: Create the constructor in the constructor, save the pointer in a member variable and then only call show on it in your method.
    how do i save the pointer in a member variable?
    i assume you mean "web"
    and how do i only call show in the method?
    I want the widget to display immediately after selecting the menu item

    so it should like this
    the slot function gets called from a menu item
    Qt Code:
    1. void test::web() {
    2. webapp::webapp(*parent);
    To copy to clipboard, switch view to plain text mode 
    which calls this
    Qt Code:
    1. webapp::webapp(QWidget* parent) {
    2. QWidget *web = new webapp(this);
    3. web->resize(1000, 350);
    4. web->show();
    5. view = new QWebView(this);
    6. view->show();
    7. }
    To copy to clipboard, switch view to plain text mode 
    It doesnt work, the program runs but the new widget doesnt display

  3. #3
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Yes, because both widget gets "this" as parent. If you want your webview to be shown inside "web", pass web as the parent to the webview.

    Then do not use QWidget as baseclass for web but QDialog so it will be shown in a new window on the screen.
    It's nice to be important but it's more important to be nice.

  4. #4
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    Still does not bring up a new dialog

    Qt Code:
    1. class webapp : public QDialog {
    2. Q_OBJECT
    3. public:
    4. webapp(QDialog* parent);
    5. .............
    6. void test::web() {
    7. webapp::webapp(*parent);
    8. }
    9. webapp::webapp(QDialog* parent) {
    10. QDialog *web = new webapp(this);
    11. web->show();
    12. view = new QWebView(web);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Please find the attached example.
    Attached Files Attached Files
    It's nice to be important but it's more important to be nice.

  6. The following user says thank you to axeljaeger for this useful post:

    chrisb123 (24th October 2009)

  7. #6
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    thanks, i'll have to study this tonight at work

  8. #7
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    I dont have main because it is a plasma widget
    It's setup like the example you gave me

    Qt Code:
    1. mum::mum(QObject *parent, const QVariantList &args)
    2. : Plasma::Applet(parent, args),
    3. m_svg(this),
    4. m_icon("document"),
    5. m_webapp(NULL),
    6. m_setapp(NULL)
    7. {
    8. m_webapp = new webapp(this);
    9. m_setapp = new setapp();
    10. }
    11. void mum::settings() {
    12. m_setapp->show();
    13.  
    14. }
    15. void mum::web() {
    16. m_webapp->show();
    17. }
    To copy to clipboard, switch view to plain text mode 

    setapp works as expected
    webapp gives the following error

    Qt Code:
    1. mum.cpp: In constructor 'mum::mum(QObject*, const QVariantList&)':
    2. mum.cpp:30: error: no matching function for call to 'webapp::webapp(mum* const)'
    3. webapp.h:33: note: candidates are: webapp::webapp(QWidget*)
    To copy to clipboard, switch view to plain text mode 
    Last edited by chrisb123; 25th October 2009 at 11:14.

  9. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Looks like Plasma::Applet does not inherit QWidget. OK, then you can't have that as parent, just pass NULL as parent and delete webapp in your destructor.
    It's nice to be important but it's more important to be nice.

  10. #9
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    how would i make it show the exisitng m_webapp from m_setapp?

  11. #10
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Either create m_webapp inside m_setapp or have m_setapp emit a signal and connect that to the show-slot of m_webapp.
    It's nice to be important but it's more important to be nice.

  12. #11
    Join Date
    Oct 2009
    Posts
    31
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default Re: closing a dialog

    Quote Originally Posted by axeljaeger View Post
    Either create m_webapp inside m_setapp or have m_setapp emit a signal and connect that to the show-slot of m_webapp.
    I'll have to read up on that

    I want the widget to not create the web app utill its called for e.g.
    Qt Code:
    1. void mum::web() {
    2. if ( ! m_webapp ) {
    3. m_webapp = new webapp(NULL);
    4. }
    5. m_webapp->show();
    6. }
    To copy to clipboard, switch view to plain text mode 
    How do I destroy m_webapp after closing it?

  13. #12
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Platforms
    MacOS X Unix/X11
    Thanks
    1
    Thanked 52 Times in 52 Posts

    Default Re: closing a dialog

    Just delete it in the destructor. (once in the lifetime of your application).
    It's nice to be important but it's more important to be nice.

Similar Threads

  1. Closing a dialog using a button
    By srohit24 in forum Qt Programming
    Replies: 5
    Last Post: 21st July 2009, 05:57
  2. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  3. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04
  4. Replies: 9
    Last Post: 13th August 2008, 18:07
  5. closing dialog in hidden main Widget
    By Lele in forum Qt Programming
    Replies: 3
    Last Post: 6th December 2006, 10:35

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.