Results 1 to 7 of 7

Thread: How to change initial visibilty in QTCreator?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to change initial visibilty in QTCreator?

    Quote Originally Posted by t_s View Post
    Mkay...now, I am confused. How come then I see every widget without having used a single show?
    Probably thanks to that "show()" in your main() which I guess is there.

    You talk about inheritance and from what I've read before about how QT works, am I to assume that the show command (the only one I found in all of the code) used for the main window somehow affects all its children individually?
    Inheritance has nothing to do with it. With inheritance I was referring to your idea of modifying auto-generated code.

    And yes, exactly as the docs say, making a widget visible makes all its children visible unless they were explicitely hidden.

    If so I really need to sit down and read through the docs.
    You do but not because of the reason you mentioned.

    Well, I mistakingly assumed I wouldn't need to re-learn much, which is my fault but then again I am posting in the newbie section of the forum so I am quite aware of that.
    But still you make firm statements about what is and what is not.

    I am not quite sure what you're talking about but what I do does work (which I assume it should?)
    Then take a text editor, open the file generated from your ui file (which is called ui_nameofthefile.h) and check its contents. Happy "enlightening".

    Qt Code:
    1. ui->nameofwdigetinquestion->setVisible(0);
    To copy to clipboard, switch view to plain text mode 
    in the constructor of the main window works perfectly fine.
    Sure it does. "ui->nameofwidgetinquestion" is a widget while "ui" is not.

    I just thought there must be a much better way to do this (like through adding custom settings, setVisible and so on, in the form editor).
    Yes, there is. Simply call "show()".

    Anyway, skimming through that link and some other examples, as I understand it, if I want to custom-make a certain widget, I include the ui-file, re-declare a constructor with the same name, and customize it the way I want. Am I getting the hang of it or am I just far out there?
    You are wrong but not very far from the truth. You can either follow the is-a concept (by inheriting the ui component) or the has-a concept (by making it a member of your widget subclass). You don't touch the constructor of the ui component but you implement the constructor of your subclass of the widget class. Just as written in the docs.

    Again, thanks for taking the time, you're like the only person in three different qt-forums who has even bothered to try answer that question for me...
    That's because this is the Ultimate Qt Community site, not just some forum
    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.


  2. The following user says thank you to wysota for this useful post:

    t_s (22nd May 2009)

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.