Results 1 to 2 of 2

Thread: How to set a custom widget on to mainwindow in designer

  1. #1
    Join Date
    Sep 2011
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5

    Default How to set a custom widget on to mainwindow in designer

    This is the first time I'm using a designer, though I've been working on Qt for quite some time now.

    Consider the QWidget & QMainWindow created using designer doesn't have header & source files generated. I need to set a custom QWidget created through as central widget to QMainWindow. A header file is getting generated automatically for each of the form. But if I cannot edit it as my changes would be lost.

    In my case -
    app_view.ui represents QMainWindow and
    pstate.ui represents QWidget (This should be set as central widget for the above mentioned QMainWindow)

    How do I achieve this? Kindly help me. Thanks.

    I'm using Qt 4.8 in Visual Studio 2008.

  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: How to set a custom widget on to mainwindow in designer

    Multiple options:

    1) in C++ create an instance of the widget and set it as the central widget
    2) in Designer add a widget to the central widget and promote it to your widget
    3) in Designer promote the central widget to your widget


  3. The following user says thank you to anda_skoa for this useful post:

    rawfool (25th December 2014)

Similar Threads

  1. Add custom widget to a mainwindow
    By aguleo in forum Newbie
    Replies: 4
    Last Post: 7th May 2013, 15:49
  2. Replies: 1
    Last Post: 24th June 2011, 00:09
  3. Replies: 9
    Last Post: 12th November 2010, 15:50
  4. Replies: 1
    Last Post: 6th May 2010, 11:09
  5. Add a custom widget in code to a MainWindow
    By Steff in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2009, 08:17

Tags for this Thread


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.