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



  • 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;
    }@



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



  • Tab header, only. I forgot mention this.



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



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



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



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



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



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.