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. [SOLVED]How I can receive real QToolBox tab geometry?

[SOLVED]How I can receive real QToolBox tab geometry?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 6.8k Views
  • 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.
  • C Offline
    C Offline
    count
    wrote on last edited by
    #1

    Greetings.

    I want to know real QToolBox tab geometry, at least - size. May be somebody knows, how I can receive it.

    Now i work with QToolBox tabs like QAbstractButtons:
    @QObjectList l = toolBox->children();
    for (QObjectList::iterator it = l.begin(); it < l.end(); it++)
    if (QAbstractButton *btn = dynamic_cast<QAbstractButton *>(*it))@
    But its geometry doesn't affect real tab size.

    Any ideas?

    Thanks for watch.

    UPD
    @template <class type>
    int QuestionList::dragEvent(type *event)
    {
    if (toolBox->geometry().contains(event->pos())
    && event->mimeData()->hasFormat("question")) {
    QAbstractButton *prev = 0;
    QAbstractButton *cur = 0;
    QObjectList l = toolBox->children();
    for (int i = 0; i < l.count(); i++) {
    prev = cur;
    if (cur = dynamic_cast<QAbstractButton *>(l.at(i))) {
    QStyleOptionToolBoxV2 *option = new QStyleOptionToolBoxV2;
    option->initFrom(cur);
    QRect buttonGeometry = cur->style()->subElementRect(QStyle::SE_ToolBoxTabContents, option);
    buttonGeometry.setTop(buttonGeometry.top() + cur->geometry().top());
    if (buttonGeometry.contains(cur->pos())) {
    buttonGeometry.setHeight(buttonGeometry.height() / 2);
    if (buttonGeometry.contains(event->pos())
    && event->mimeData()->hasFormat("question")) {
    unlightHighlight(prev, cur);
    event->acceptProposedAction();
    return cur->text().section(QChar(0x2116), -1).toInt();
    } else {
    buttonGeometry.setTop(buttonGeometry.top() + buttonGeometry.height());
    if (buttonGeometry.contains(event->pos())
    && event->mimeData()->hasFormat("question")) {
    prev = cur;
    cur = 0;
    for (i++; !cur && i < l.count(); i++)
    cur = dynamic_cast<QAbstractButton *>(l.at(i));
    unlightHighlight(prev, cur);
    event->acceptProposedAction();
    return prev->text().section(QChar(0x2116), -1).toInt() + 1;
    }
    }
    }
    }
    }
    if (!toolBox->count()) {
    event->acceptProposedAction();
    return 0;
    }
    }
    unlight();
    event->ignore();
    return 0;
    }@

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dangelog
      wrote on last edited by
      #2

      What do you mean with "tab geometry"? The geometry of the tab header or the tab header + the corresponding widget?

      Software Engineer
      KDAB (UK) Ltd., a KDAB Group company

      1 Reply Last reply
      0
      • C Offline
        C Offline
        count
        wrote on last edited by
        #3

        Tab header, only. I forgot mention this.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          The tab is drawn with a style. Maybe you can get the sizes with "QStyle::subControlRect() ":http://doc.trolltech.com/latest/qstyle.html#subControlRect or "QStyle::subElementRect() ":http://doc.trolltech.com/latest/qstyle.html#subElementRect.

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

          1 Reply Last reply
          0
          • D Offline
            D Offline
            dangelog
            wrote on last edited by
            #5

            Why do you say that its geometry doesn't affect the real size? Can you paste a testcase?

            Software Engineer
            KDAB (UK) Ltd., a KDAB Group company

            1 Reply Last reply
            0
            • C Offline
              C Offline
              count
              wrote on last edited by
              #6

              [quote author="peppe" date="1292505176"]Why do you say that its geometry doesn't affect the real size? Can you paste a testcase?[/quote]

              Because its geometry doesn't include area with tab header decoration line.

              Yes, of course, I add it to post.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                count
                wrote on last edited by
                #7

                [quote author="Volker" date="1292497331"]The tab is drawn with a style. Maybe you can get the sizes with "QStyle::subControlRect() ":http://doc.trolltech.com/latest/qstyle.html#subControlRect or "QStyle::subElementRect() ":http://doc.trolltech.com/latest/qstyle.html#subElementRect.[/quote]

                Thank you very much, may be it is a way out for me. I trying to use it, but it doesn't work as i want, may be i do something wrong.

                I paste code which i use into the post. May be you can help me.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  I don't know what exactly you want to do. Could you explain a bit more in detail. Maybe there is another way to achieve the same.

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

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    count
                    wrote on last edited by
                    #9

                    I want to implement drag&drop of tab-widgets between multiple QToolBox.
                    When the drag is initialized current widgets QScrollArea is hidden, and ToolBox consists only from tab headers, I need to know which tab header under mouse.

                    If there is any way to do it correctly?

                    I want to use QToolBox because of it beautiful design and policy which autohide all non active widgets.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      count
                      wrote on last edited by
                      #10

                      Now i need to add some new functionality which can not be added via QToolBox. Now i write my box-class.

                      Thank to all very much.

                      And excuse me for my bad English.

                      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