Results 1 to 4 of 4

Thread: when i click a button in the menubar i want to open a new window?

  1. #1
    Join Date
    Feb 2012
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default when i click a button in the menubar i want to open a new window?

    Hello

    I'm searching on this site on how to open a new window when you click a button in the menubar.
    But i really can't find a solution for my problem.

    So can someone pls help. Than you Very Much.

  2. #2
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: when i click a button in the menubar i want to open a new window?

    Connect your button to slot, for example "slotOpen()", and in this slot show your new window
    Qt Code:
    1. void MainWindow::slotOpen()
    2. {
    3. QWidget *wgt = new QWidget( this );
    4. wgt->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2012
    Posts
    19
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: when i click a button in the menubar i want to open a new window?

    Quote Originally Posted by Jonny174 View Post
    Connect your button to slot, for example "slotOpen()", and in this slot show your new window
    Qt Code:
    1. void MainWindow::slotOpen()
    2. {
    3. QWidget *wgt = new QWidget( this );
    4. wgt->show();
    5. }
    To copy to clipboard, switch view to plain text mode 
    This is the code than.
    but when i click buton there opens no window


    1. #include "mainwindowimpl.h"
    2. #include <QMenuBar>
    3. #include <QWidget>
    4. //
    5. MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
    6. : QMainWindow(parent, f)
    7. {
    8. setupUi(this);
    9. }
    10. //
    11. void MainWindowImpl::slotOpen()
    12. {
    13. QWidget *wgt = new QWidget( this );
    14. wgt->show();
    15. }
    16. void MainWindowImpl:n_buton_clicked()
    17. {
    18. slotOpen();
    19. }

  4. #4
    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: when i click a button in the menubar i want to open a new window?

    Do you have a "buton" (note the single "t") object anywhere in the ui file?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 2
    Last Post: 28th November 2011, 15:12
  2. Replies: 0
    Last Post: 8th November 2011, 11:16
  3. Replies: 3
    Last Post: 23rd December 2010, 06:55
  4. Replies: 0
    Last Post: 10th September 2010, 13:23
  5. How to open any file on button click???
    By r3aktor in forum Newbie
    Replies: 5
    Last Post: 8th July 2009, 08:54

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.