Results 1 to 7 of 7

Thread: QToolBox and style

  1. #1
    Join Date
    Jan 2006
    Posts
    14
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question QToolBox and style

    I'm working on a style for KDE and I'm having a lot of trouble with that QToolBox.

    I dug deep into KDE and Qt sources and docs and I know how to style a CE_ToolBoxTab --upto the limits imposed by Qt-- but there's something I don't know how to do: To get the index of the toolbox tab corresponding to the widget I'm painting. I need that index to adapt the drawing to the position of the tab, especially for the first and last tab.

    I tried various way and the least stupid one IMHO is:

    const QToolBox* tb = (const QToolBox*) widget;
    int count = tb->count();
    int index = tb->indexOf( (QWidget*)widget );
    It's modelled on the way to get the index of a regular tab... but it doesn't work. index is always -1 as if widget doesn't exist.

    Can someone explain what I'm doing wrong?

    Please, don't hesitate to use very simple words and to call me a noob.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QToolBox and style

    Quote Originally Posted by Maxilys
    Qt Code:
    1. const QToolBox* tb = (const QToolBox*) widget;
    2. int count = tb->count();
    3. int index = tb->indexOf( (QWidget*)widget );
    To copy to clipboard, switch view to plain text mode 
    It looks like you are trying to get the index of the toolbox itself (widget == tb). In the third line you should use the variable that points to the tab instead of widget.

  3. #3
    Join Date
    Jan 2006
    Posts
    14
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question Re: QToolBox and style

    I know, the third line is, well, circular. I read Qt sources a little too quickly. widget is in fact the parent of the toolbox tab I have to draw.

    Now, the question is: How can I find the widget I'm actually drawing with the few informations I have? All I know for sure is the parent widget and the containing rectangle of the widget I'm looking for. That's not much.

    I thought that this code should be a step in the right direction:

    Qt Code:
    1. int index = tb->indexOf( tb->childAt(left,top) );
    To copy to clipboard, switch view to plain text mode 

    But it doesn't work either. I also tried childAt( r.center() ), all the available mappings although Qt docs don't said any should be necessary. It made no difference.

    The noob I am needs a much bigger push in the right direction...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QToolBox and style

    Maybe you should try peeking Qt sources to see if the default styles use something simmilar?

  5. #5
    Join Date
    Jan 2006
    Posts
    14
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QToolBox and style

    I wish it was that simple! Reading Qt and KDE sources is my first move to find the limitations of what I can do. Next, I read what some other styles do.

    In this case, nobody cares about QToolBox except Qt... and the default style draws all the toolbox tabs the same way unless it's selected. Useless.

    I'm gonna ask to the KDE Dev list --if they're not too busy-- then I'll go to the real source of Qt: the Trolls of Trolltech. I've been told they know a little more about Qt than anybody.

  6. #6
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QToolBox and style

    I styled the QToolBox widget in my Phase style, included in kdeartwork. It was written for Qt3. I don't know how well the KDE4 porting guys did moving it to Qt4. Anyway, it's there and hopefully easy to understand.

  7. The following user says thank you to Brandybuck for this useful post:

    Maxilys (26th March 2006)

  8. #7
    Join Date
    Jan 2006
    Posts
    14
    Thanks
    1
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: QToolBox and style

    Quote Originally Posted by Brandybuck
    I styled the QToolBox widget in my Phase style, included in kdeartwork. It was written for Qt3. I don't know how well the KDE4 porting guys did moving it to Qt4. Anyway, it's there and hopefully easy to understand.
    That's right you styled the QToolBox but you just reproduced the Qt look and there is no mouseover effect on the tooltabs. But it doesn't matter. Look at my QToolbox. I think I can leave it this way until Qt5 (and I mean 5, not 4) since there is no improvement of the QToolBox in Qt4. "They" just adapted the source but the widget's handling is unchanged. So... Let's forget about it.

    If I'm saying "thank you" that's because your style gave me some answers to some problems I have with my style... and the source is legible. I'm gonna schedule a meeting with my friends Cut & Paste.

Similar Threads

  1. QToolBox qss style sheet problem
    By eskil in forum Qt Programming
    Replies: 1
    Last Post: 17th August 2007, 17:45

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.