Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using methods from private classes
Forum Updated to NodeBB v4.3 + New Features

Using methods from private classes

Scheduled Pinned Locked Moved Solved General and Desktop
qtreeview
5 Posts 3 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eska2000
    wrote on last edited by
    #1

    Hi.

    I need to check whenever user press on the string or folders sign on QTreeView.
    I saw qt source of mousePressEvent:

    void QTreeView::mousePressEvent(QMouseEvent *event)
    {
        Q_D(QTreeView);
        bool handled = false;
        if (style()->styleHint(QStyle::SH_ListViewExpand_SelectMouseType, 0, this) == QEvent::MouseButtonPress)
            handled = d->expandOrCollapseItemAtPos(event->pos());
        if (!handled && d->itemDecorationAt(event->pos()) == -1)
            QAbstractItemView::mousePressEvent(event);
    }
    

    There are using of the expandOrCollapseItemAtPos(QPos *) and itemDecorationAt(QPos *) methods. These methods located in the QTreeViewPrivate class.
    Can I use these methods? Is it legal?
    Do I need to reimplement QTreeViewPrivate class to use these methods?

    Thank you.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Can I use these methods? Is it legal?

      Yes you can. You need to include widgets-private in QT variable in qmake to do so.

      Remember, though, that these methods are called private for a reason - normally users do not need to use them. Also, Qt does not offer any source / binary compatibility promises for private classes.

      Are you sure you can't achieve your goals without private classes?

      (Z(:^

      E 1 Reply Last reply
      4
      • sierdzioS sierdzio

        Can I use these methods? Is it legal?

        Yes you can. You need to include widgets-private in QT variable in qmake to do so.

        Remember, though, that these methods are called private for a reason - normally users do not need to use them. Also, Qt does not offer any source / binary compatibility promises for private classes.

        Are you sure you can't achieve your goals without private classes?

        E Offline
        E Offline
        eska2000
        wrote on last edited by
        #3

        @sierdzio , thank you! I will try to solve my task by another way.

        mrjjM 1 Reply Last reply
        0
        • E eska2000

          @sierdzio , thank you! I will try to solve my task by another way.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @eska2000
          Hi
          There is signals for when it's expanded / collapsed.

          If you tell what task is, maybe someone knows good way to solve it. :)

          E 1 Reply Last reply
          0
          • mrjjM mrjj

            @eska2000
            Hi
            There is signals for when it's expanded / collapsed.

            If you tell what task is, maybe someone knows good way to solve it. :)

            E Offline
            E Offline
            eska2000
            wrote on last edited by
            #5

            @mrjj
            My task is to drag items from QTreeView to another widget.
            But when I try to drag item this item makes selected. I need to drag items without selection them.
            So I want to reimplement mousePressEvent.
            But I still need to collapse/expand items, so if I reimplement mousePressEvent I need to see which area of the item (string or sign) user pressed.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved