Results 1 to 7 of 7

Thread: How to change initial visibilty in QTCreator?

  1. #1
    Join Date
    May 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question How to change initial visibilty in QTCreator?

    I've noticed that there are no visibility options for any (well, can't say 100% but for all those I've used) widgets and if I add it (setVisible(0)/setVisible(false)) as a dynamic propery it is ignored.
    Also since there is a bare minimum c-code generated by the ui-designer (why? can't do anything useful with the .ui-file that I can't do in the designer anyway) I can't manually change this. The only way for me to do it now is in the constructor of the main window which is a very ugly way of doing it IMO.

    So my question is, how is one supposed to do it "properly" in the creator?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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?

    Visibility of what? As for the ui file, it is supposed to be that way. Read this: Using a Designer .ui File in Your Application
    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.


  3. #3
    Join Date
    May 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to change initial visibilty in QTCreator?

    Quote Originally Posted by wysota View Post
    Visibility of what? As for the ui file, it is supposed to be that way. Read this: Using a Designer .ui File in Your Application
    Errr...thanks for answering but did you read my post or just reply to the title? The initial visibilty of any widget (at run-time), controlled by setVisible, show, hide you name it. Perhaps there was something confusing in my initial post?

    As for the other question, I'm yet to read through all that (tthe link). It's just that I'm used to utilizing IDE:s to generate a base code I then can edit to fit my purpose. I'm sure there are some smart concepts behind the QT approach, but a little frustrating when I get stuck as in my case above.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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
    Perhaps there was something confusing in my initial post?
    Yes there was. Don't abuse the word "Creator" because it leads to confusion. You should have asked about initial visibility of the form in your program that you create in Creator (or in fact Designer). Then I would have said that widgets are hidden by default and you should show() them in your code. Then you would have asked how to do that and then I would point you to the link I did point you to. So cutting to the chase - your question was answered by the link I gave you.

    As for the other question, I'm yet to read through all that (tthe link)
    Then read the link and the answer(s) to your question(s) will become obvious.

    . It's just that I'm used to utilizing IDE:s to generate a base code I then can edit to fit my purpose. I'm sure there are some smart concepts behind the QT approach, but a little frustrating when I get stuck as in my case above.
    You're used to stupid IDEs that don't give a damn about inheritance. Qt does so you do all that you say by subclassing and not editing auto-generated code.

    And by the way - learning some things first before giving opinions about them is a really good idea. You got stuck because you started coding before learning and expected something to work exactly as you're used to with some other mechanism and finding that things are a bit different you assumed that everything must be different. Just as you didn't notice that the code generated from the .ui file is not a widget so calling show(), hide() or setVisible() on it wouldn't make any sense.
    Last edited by wysota; 20th May 2009 at 22:35.
    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.


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

    t_s (22nd May 2009)

  6. #5
    Join Date
    May 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to change initial visibilty in QTCreator?

    Quote Originally Posted by wysota View Post
    Yes there was. Don't abuse the word "Creator" because it leads to confusion. You should have asked about initial visibility of the form in your program that you create in Creator (or in fact Designer). Then I would have said that widgets are hidden by default and you should show() them in your code. Then you would have asked how to do that and then I would point you to the link I did point you to. So cutting to the chase - your question was answered by the link I gave you.
    Mkay...now, I am confused. How come then I see every widget without having used a single show? 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?
    If so I really need to sit down and read through the docs.

    Quote Originally Posted by wysota View Post
    And by the way - learning some things first before giving opinions about them is a really good idea.
    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.

    Quote Originally Posted by wysota View Post
    Just as you didn't notice that the code generated from the .ui file is not a widget so calling show(), hide() or setVisible() on it wouldn't make any sense.
    I am not quite sure what you're talking about but what I do does work (which I assume it should?)
    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. 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).

    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?

    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...

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 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.


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

    t_s (22nd May 2009)

  9. #7
    Join Date
    May 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: How to change initial visibilty in QTCreator?

    Heh, do I feel dense now or what (I finally managed to figure it all out this morning)???
    Anyway, many thanks for helping me help myself..

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.