Results 1 to 3 of 3

Thread: How to convert a QWidget into a QMainWindow

  1. #1
    Join Date
    Aug 2010
    Posts
    22
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to convert a QWidget into a QMainWindow

    Hi, I created a QWidget with controls in it. But now I need to put a menu into it, but how to convert it to a QMainWindow easily, without creating another form and paste the controls into it?

    I tried to modify the ui file and changed the QWidget to QMainWindow, but the Designer complained when it open the file.

    Thanks.

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to convert a QWidget into a QMainWindow

    You don't need to convert your QWidget into a QMainWindow.
    You can create a new QMainWindow and use it's setCentralWidget() member function to make your widget appear in the main window.

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

    jezz (16th September 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    22
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to convert a QWidget into a QMainWindow

    Quote Originally Posted by Zlatomir View Post
    You don't need to convert your QWidget into a QMainWindow.
    You can create a new QMainWindow and use it's setCentralWidget() member function to make your widget appear in the main window.
    Thanks, but I would like everything to be in one file, since they are all related.
    Nice to know this tip though, will be using it one day.

Similar Threads

  1. Difference between QWidget and QMainWindow
    By daviddoria in forum Newbie
    Replies: 9
    Last Post: 9th July 2018, 19:06
  2. how to resize Qmainwindow with Qwidget ?
    By zeynepb.bil in forum Qt Programming
    Replies: 10
    Last Post: 28th September 2017, 23:48
  3. QWidget on QMainWindow
    By jayreddy in forum Qt Programming
    Replies: 4
    Last Post: 6th January 2010, 08:27
  4. Convert QWidget to QVariant How to?
    By sergey_85 in forum Qt Programming
    Replies: 3
    Last Post: 15th December 2009, 07:21
  5. Resize QWidget in QMainWindow
    By aamer4yu in forum Qt Programming
    Replies: 1
    Last Post: 8th March 2007, 12:16

Tags for this Thread

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.