Results 1 to 3 of 3

Thread: accessing one dialog from another

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default accessing one dialog from another

    Hi folks,

    I have a simple program with a main window and two dialogs. My file list is main.cpp, mainwindow.cpp, mainwindow.h, dlg1.cpp, dlg1.h, dlg2.cpp and dl2.h.

    On mainwindow.cpp, I have this:

    d1 = new dlg1;
    d2 = new dlg2;

    Now, when the user presses a button in dlg1, I would like dlg2 to come up. Perhaps I could just connect the button signal of dlg1 to a function in mainwindow. How do I do this? Any code snippets?

    Is there any other way to directly access one dialog from another? The problem is getting dlg1 to know that d2 exists of type dlg2. I don't know how it can be done.

    Thanks,

    Ricky.

  2. #2
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: accessing one dialog from another

    mainwindow.h
    Qt Code:
    1. {
    2. public slots:
    3. void popup();
    4. }
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. d1 = new dlg1;
    2. d2 = new dlg2;
    3.  
    4. connect (d1->popupButton, SIGNAL(clicked()), this, SLOT(popup()));
    5.  
    6. void MainWindow::popup()
    7. {
    8. d2->show();
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by THRESHE; 18th March 2008 at 16:16.
    C++ & AMD forever

  3. #3
    Join Date
    Mar 2008
    Posts
    5
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: accessing one dialog from another

    Thanks! This was easier than expected. I suddenly feel very stupid

    Ricky.

Similar Threads

  1. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  2. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48
  3. Replies: 3
    Last Post: 23rd July 2006, 18:02
  4. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22
  5. Dialog positioning in GNOME
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 09:41

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.