Results 1 to 6 of 6

Thread: Adding QTCheckBox Manually

  1. #1
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Adding QTCheckBox Manually

    I have primarily always used QTCreator to build the GUI for my QT projects. I want to add a QCheckBox manually but I'm not sure how to go about it. I went into my ui_mainwindow header and added a new QCheckBox object while calling setObjectName, setObjectGeometry, raise(), etc., as the generated files do for all my other GUI objects, but nothing was visible. I am reading something about a QCheckBox needing to be put into a QTableWidget or something along those lines? How can I program this into my auto generated UI header file without having to resort to QTCreator?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Adding QTCheckBox Manually

    You cannot put it in the auto-generated UI code because, well, that code is automatically generated and will be overwritten if the *.ui file is changed.

    You can either:
    • build the entire UI in code in your class constructor (like the majority if the Qt examples), or
    • allow the Designer UI to initialise (i.e. setupUi(this)) and then create a QCheckBox object and insert it into a layout that the generated UI contains.

  3. #3
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding QTCheckBox Manually

    Quote Originally Posted by ChrisW67 View Post
    You cannot put it in the auto-generated UI code because, well, that code is automatically generated and will be overwritten if the *.ui file is changed.

    You can either:
    • build the entire UI in code in your class constructor (like the majority if the Qt examples), or
    • allow the Designer UI to initialise (i.e. setupUi(this)) and then create a QCheckBox object and insert it into a layout that the generated UI contains.
    I think you misunderstand. My .ui file is long gone for this project, so my only option is to add it manually. I need to know how to add a QCheckBox manually with nothing more than the auto generated header files I was originally given through QTCreator. I would normally add it through QTCreator but my .ui file is gone, as I said, so I need to add it manually.

  4. #4
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 8 Times in 8 Posts

    Default Re: Adding QTCheckBox Manually

    If you have Qt Designer installed on your machine then open designer create one frame or main window and add QCheckBox on it.
    Now go to menu and select Form > View Code...
    this will show you code for your current ui file from which you can get idea how to add QCheckBox programmatically.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Adding QTCheckBox Manually

    Quote Originally Posted by QTNovice View Post
    added a new QCheckBox object while calling setObjectName, setObjectGeometry, raise(), etc., as the generated files do for all my other GUI objects, but nothing was visible
    Did you add it to the layout?

    Quote Originally Posted by QTNovice View Post
    I would normally add it through QTCreator but my .ui file is gone, as I said, so I need to add it manually.
    It might be better to invest a couple of minutes and recontruct the UI file instead.

    How did you end up in this situation? Added the generated file to you version control system instead of the UI file?

    Cheers,
    _

  6. #6
    Join Date
    Sep 2013
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Adding QTCheckBox Manually

    I ended up in the situation simply because the project I am working on is very old and I saved the project but lost the UI file when I reformatted.

    I figured it all out though, so thanks for the help.

Similar Threads

  1. Replies: 4
    Last Post: 8th April 2013, 04:19
  2. Replies: 3
    Last Post: 30th January 2012, 09:44
  3. How to manually pan canvas
    By novackb in forum Qwt
    Replies: 4
    Last Post: 18th February 2011, 17:46
  4. how to show an app if it manually hide
    By jthacker in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2010, 13:02
  5. Manually using RCC compiler?
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 18th May 2007, 07:47

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.