跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  2. Qt Development
  3. General and Desktop
  4. Suggestion in Qt Creator content assist for QScopedPointer
Forum Updated to NodeBB v4.3 + New Features

Suggestion in Qt Creator content assist for QScopedPointer

已排程 已置頂 已鎖定 已移動 General and Desktop
27 貼文 9 Posters 15.3k 瀏覽 1 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • A 離線
    A 離線
    ashwindas
    寫於 最後由 編輯
    #1

    I have a suggestion to Qt creator - [I am currently using Qt Creator 2.0.94 (2.1.0-rc1)--]

    When I am coding with pointers like for eg -
    @ QGridLayout* layout = new QGridLayout();
    @
    later after this if I type layout followed by a dot .. it changes to layout-> automatically and shows a content assist with the avialable functions and variables etc., making my life easy.

    But when I am using a QScopePointer like -
    @QScopedPointer<QTableView> table(new QTableView);@

    and now to get the content assist for functions in the QTableView, I have to manually enter both - and > like table->, which requires 3 key press, - followed by Shift + . (>)

    This is not a major concern but is slightly irritating. Most of the time we will be working on methods in QTableView and use function like reset and others in QScopePointer in a relatively smaller percent. So having to remember to type -,> every time is a bit annoying.

    So can this be changed and made such that a dot following a QScopePointer behaves in a similar way to normal pointer.

    This is also the case with other such classes like QSharedPointer and QPointer etc..
    and I type table followed by dot, it shows the functions available from the QScopedPointer

    1 條回覆 最後回覆
    0
    • ZlatomirZ 離線
      ZlatomirZ 離線
      Zlatomir
      寫於 最後由 編輯
      #2

      I'm somehow against this, and the same behavior for "normal" pointers, this increase the confusion some people have between a pointer and an object, and writing the "arrow" operator it's not the end of the world... that is what we do, we write code ;)

      And another issue is how do you call reset(...) member function for your scoped pointer after Trolls make Creator replace . automatically with ->?

      https://forum.qt.io/category/41/romanian

      1 條回覆 最後回覆
      0
      • I 離線
        I 離線
        ixSci
        寫於 最後由 編輯
        #3

        Ashwin Das, if you use smart pointers overloaded operator -> more often then . doesn't mean others use it as you do.

        1 條回覆 最後回覆
        0
        • P 離線
          P 離線
          Panke
          寫於 最後由 編輯
          #4

          [quote author="Zlatomir" date="1293809715"]
          And another issue is how do you call reset(...) member function for your scoped pointer after Trolls make Creator replace . automatically with ->?[/quote]

          That's the point.

          1 條回覆 最後回覆
          0
          • A 離線
            A 離線
            ashwindas
            寫於 最後由 編輯
            #5

            [quote author="Zlatomir" date="1293809715"]I'm somehow against this, and the same behavior for "normal" pointers, this increase the confusion some people have between a pointer and an object, and writing the "arrow" operator it's not the end of the world... that is what we do, we write code ;)

            And another issue is how do you call reset(...) member function for your scoped pointer after Trolls make Creator replace . automatically with ->?[/quote]

            Yes that makes sense, so it can be such that when I type -, the -> comes up. Which would be easier. Now it is bit complicated. I want it to be easier.

            [quote author="ixSci" date="1293818511"]Ashwin Das, if you use smart pointers overloaded operator -> more often then . doesn't mean others use it as you do. [/quote]

            ixSci, even others uses -> more often as I do

            1 條回覆 最後回覆
            0
            • I 離線
              I 離線
              ixSci
              寫於 最後由 編輯
              #6

              [quote]ixSci, even others uses -> more often as I do[/quote]
              Why are you so sure about it? Can you present some evidence about it? because at least I don't use it more often.

              1 條回覆 最後回覆
              0
              • A 離線
                A 離線
                ashwindas
                寫於 最後由 編輯
                #7

                [quote author="ixSci" date="1293885083"][quote]ixSci, even others uses -> more often as I do[/quote]
                Why are you so sure about it? Can you present some evidence about it? because at least I don't use it more often.[/quote]

                Eg: When using
                @QScopedPointer<QTableView> table(new QTableView);@

                next usage would be
                @table->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
                table->horizontalHeader()->setStretchLastSection(true);
                table->setmodel(model);
                table->setSelectionModel(selectionModel);
                table->resizeColumnsToContents();@

                this can go on.. and for my custom objects which have their own functions I will call them in similar fashion. QScopedPointer has functions like isNull, reset etc..
                reset will be used only when changing the object..
                It doesn't make more sense to use functions like reset() more than I use my objects functions now does it?
                In most of my use cases..Will I be creating more objects using reset() etc and use the objects functions only once/twice or lesser than that? definitely not.

                ixSci, can you present evidence of your usage.

                1 條回覆 最後回覆
                0
                • G 離線
                  G 離線
                  goetz
                  寫於 最後由 編輯
                  #8

                  Ashwin, if Creator would automatically change "table." to "table->" when typing, you would never be able to write "table.reset()", because it always would be changed to "table->reset()" even if you try to change it afterwards.

                  This is in no means related to the frequency you use it, it's simply that it prevents other things to ever work.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 條回覆 最後回覆
                  0
                  • A 離線
                    A 離線
                    ashwindas
                    寫於 最後由 編輯
                    #9

                    Volker, yes I understood that, that is the reason I suggested this in my previous comment -

                    [quote author="Ashwin Das" date="1293883792"]
                    Yes that makes sense, so it can be such that when I type -, the -> comes up. Which would be easier. Now it is bit complicated. I want it to be easier.
                    [/quote]

                    1 條回覆 最後回覆
                    0
                    • G 離線
                      G 離線
                      goetz
                      寫於 最後由 編輯
                      #10

                      Ok, I understood now. I personally do not have a problem with that and do not see much sense in it. But anyways, just open a suggestion ticket on the "bug tracker": http://bugreports.qt.nokia.com and wait what the trolls will say.

                      http://www.catb.org/~esr/faqs/smart-questions.html

                      1 條回覆 最後回覆
                      0
                      • A 離線
                        A 離線
                        ashwindas
                        寫於 最後由 編輯
                        #11

                        Thanks Volker, will do that.

                        1 條回覆 最後回覆
                        0
                        • G 離線
                          G 離線
                          goetz
                          寫於 最後由 編輯
                          #12

                          And please add the link to the ticket here, once it's created, so the community can follow.

                          http://www.catb.org/~esr/faqs/smart-questions.html

                          1 條回覆 最後回覆
                          0
                          • A 離線
                            A 離線
                            ashwindas
                            寫於 最後由 編輯
                            #13

                            [quote author="Volker" date="1293905238"]And please add the link to the ticket here, once it's created, so the community can follow.[/quote]

                            "Link":http://bugreports.qt.nokia.com/browse/QTBUG-16391

                            1 條回覆 最後回覆
                            0
                            • G 離線
                              G 離線
                              goetz
                              寫於 最後由 編輯
                              #14

                              Thanks for the link. It would have been better reported in the "Qt Creator Section":http://bugreports.qt.nokia.com/browse/QTCREATORBUG of the bugtracker, but the Trolls will move it quickly, I'm sure.

                              http://www.catb.org/~esr/faqs/smart-questions.html

                              1 條回覆 最後回覆
                              0
                              • A 離線
                                A 離線
                                andre
                                寫於 最後由 編輯
                                #15

                                I don't really like converting the . to a -> for cases where the . would be a valid operator. What would be cool, is if Qt Creator would change the . into a -> if you start typing method names that are not available for the . operator, but are for the -> operator. So, to follow the example given, as soon as you start typing the 'h' for horizontal, the . would be changed for a -> as there is no method starting with a h in QScopedPointer itself. However, if you are calling the resizeColumnsToContents() method, that would only happen on when you type the 'i', as before that you could have been typing reset() as well, which exists for the . operator.

                                1 條回覆 最後回覆
                                0
                                • ZlatomirZ 離線
                                  ZlatomirZ 離線
                                  Zlatomir
                                  寫於 最後由 編輯
                                  #16

                                  Yes that would be nice, but we prefer the IDE to be fast, so that we can write code in it, not to look at the "stars" and perform God knows what "calculations" to replace my operators.

                                  //sorry for my little sarcasm ;-)

                                  Guys, we are all programmers, actually i'm not (but i want to become one), so we are programmers that means we know what we want to call and we know if what we call is member of the "smart" pointer or is member of the object pointed to... it not that complicated, and it's not where most of the typing for an application goes...
                                  And that's the beauty and power of C++: you are "in command", you got to know what are you doing, even if Qt simplifies things like memory management, Qt still relies on the strengths and weaknesses of the C++ programming language.

                                  The Trolls did that replacement for "dump" pointers, and it's ok***, since they are "dump" and don't have member functions, but for smart-pointers this would be unnecessary, my opinion.

                                  I like Creator because it's simple and fast, i like VS2010 IDE, but that is slow... and not to mention that Intelisense was the name of the functionality that freeze your IDE to help you write code...
                                  //sarcasm again, Intellisense is not that bad if it's not exaggerated with a lot of unnecessary features.

                                  ***i still consider it "not-so-good" because it might encourage people to confuse pointer with object

                                  https://forum.qt.io/category/41/romanian

                                  1 條回覆 最後回覆
                                  0
                                  • G 離線
                                    G 離線
                                    goetz
                                    寫於 最後由 編輯
                                    #17

                                    Well written, Zlatomir. It's exactly the point. And while I really do like the . to -> conversion on plain old pointers, I would argue against it for smart pointers. I would not like it to be changed afterwards (from xyz.hori to xyz->hori) because I do not like that code, that my cursor is not on, is changed automatically.

                                    [EDIT: fixed Textile markup]

                                    http://www.catb.org/~esr/faqs/smart-questions.html

                                    1 條回覆 最後回覆
                                    0
                                    • T 離線
                                      T 離線
                                      tobias.hunger
                                      寫於 最後由 編輯
                                      #18

                                      Well, if somebody really wants this, then please file a feature request in our "issue tracker":http://bugreports.qt.nokia.com/.

                                      It will be forgotten when it stays in the forums.

                                      1 條回覆 最後回覆
                                      0
                                      • G 離線
                                        G 離線
                                        goetz
                                        寫於 最後由 編輯
                                        #19

                                        [quote author="Tobias Hunger" date="1294074762"]Well, if somebody really wants this, then please file a feature request in our "issue tracker":http://bugreports.qt.nokia.com/.

                                        It will be forgotten when it stays in the forums.[/quote]

                                        That has already been done: "QTBUG-16391":http://bugreports.qt.nokia.com/browse/QTBUG-16391, unfortunately not in the Qt Creator project of the tracker, but some of the Trolls will move it?

                                        http://www.catb.org/~esr/faqs/smart-questions.html

                                        1 條回覆 最後回覆
                                        0
                                        • P 離線
                                          P 離線
                                          Panke
                                          寫於 最後由 編輯
                                          #20

                                          [quote author="Volker" date="1294062364"]Well written, Zlatomir. It's exactly the point. And while I really do like the . to -> conversion on plain old pointers, I would argue against it for smart pointers. I would not like it to be changed afterwards (from xyz.hori to xyz->hori) because I do not like that code, that my cursor is not on, is changed automatically.

                                          [EDIT: fixed Textile markup][/quote]

                                          You don't really need a feature like this -- you could use ed after all. Just kidding. I would like the feature and I'm sure it would do no harm. It might change code your cursor is not on, that's true. And I agree that this is in general a bad idea. But it is also true, that the code it changes is 4 characters left of your cursor, so no problem here.

                                          I don't miss this feature though and their are improvements that would have a bigger impact on the ways we develop our applications. Maybe this "this":http://developer.qt.nokia.com/forums/viewthread/795/ combined with model checker :-)

                                          1 條回覆 最後回覆
                                          0

                                          • 登入

                                          • Login or register to search.
                                          • 第一個貼文
                                            最後的貼文
                                          0
                                          • 版面
                                          • 最新
                                          • 標籤
                                          • 熱門
                                          • 使用者
                                          • 群組
                                          • 搜尋
                                          • Get Qt Extensions
                                          • Unsolved