Results 1 to 2 of 2

Thread: QMainWindow access children of centralWidget

  1. #1
    Join Date
    Feb 2008
    Location
    Honolulu, HI
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QMainWindow access children of centralWidget

    Hi all,

    stupid question. I use QDesigner, drew a QMainWindow with a QWidget centralWidget. Inside, there's a layout and a couple of children (buttons, tables, etc.).

    All the classes are autogenerated using QtCreator.

    My TMainWindow class looks like this:
    Qt Code:
    1. TMainWindow::TMainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::TMainWindow)
    4. {
    5. ui->setupUi(this);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Now I want to connect one of the pushButtons to qApp() / quit. But every time I type in ui->..., I can't access the pushButtons.

    When I open the designer form in QDesigner, the hierarchy is this:

    TMainWindow
    \-> centralWidget (QWidget)
    ____\-> gridLayout (QGridLayout)
    ________\-> btn_Quit (QPushButton)


    However the centralWidget has this "forbidden" icon on the lower right corner. Does this have something to do with it and how do I access the children of centralWidget?

    Thanks,
    Stephan

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: QMainWindow access children of centralWidget

    ui->btn_Quit should work.

Similar Threads

  1. QtDesigner: set centralWidget of QMainWindow
    By Florianx in forum Newbie
    Replies: 1
    Last Post: 25th June 2010, 18:17
  2. QMainWindow/centralWidget question
    By graciano in forum Qt Programming
    Replies: 6
    Last Post: 15th April 2010, 22:49
  3. QMainWindow -> centralWidget size
    By lalesculiviu in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2009, 09:40
  4. QMainWindow->centralWidget with alpha?
    By wafto in forum Newbie
    Replies: 2
    Last Post: 7th December 2008, 02:52
  5. QMainWindow: problem changing centralWidget
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 4th October 2007, 13:00

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.