Results 1 to 5 of 5

Thread: How do I get elements of a base widget?

  1. #1
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default How do I get elements of a base widget?

    Hiya,
    I have this timeline from Nuke, and I would like to style the ticks and numbers individually.
    I have the object (QWidget), that is the timeline, but I can't figure out how to get its elements (the ticks and numbers).

    I am able to style all the elements together, but I want to know how to dig deeper and style each element. I can't use .children() because it seems to be the very bottom of the group.
    I assume I now need to use the stylesheet selector tag to get the elements. How would I go about identifying the elements to use the selector.

    Please see attached image.

    60815-16x9.jpg

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How do I get elements of a base widget?

    If it is a typical custom widget, it is probably "hand-drawn" in its paintEvent() and you can't get to any sub-elements because there aren't any. Stylesheets are optional, too. If the widget supports them, then you can use QWidget::styleSheet() to get the QString representation of the style sheet and see if there are any recognizable elements in it.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    Nfrancisj (31st May 2017)

  4. #3
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I get elements of a base widget?

    THAT IS PERFECT! I was looking for .stylesheet() for a very very long time. hahaha! I've used setStyleSheet so many times, I never thought to look at the docs for .styleSheet()

    Thanks Dude!

  5. #4
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How do I get elements of a base widget?

    probably "hand-drawn" in its paintEvent()
    Diving deeper, I must confess I haven't reached the QGraphics chapter yet, is there anyway to explore Paint Elements? I assume paintEvents paint QGraphics Scene and Items, ya?

    So a standard QPushButton is constructed using the QGraphics family of classes and it's painted using a paintEvent? Is there a way to dive down into that and see what constructs the QPushButton?


    Thanks a lot, I really am learning a lot. 😁

    Cheers!

  6. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How do I get elements of a base widget?

    So a standard QPushButton is constructed using the QGraphics family of classes and it's painted using a paintEvent?
    Yes, it is drawn using a paintEvent() (as are all QWidget-based classes), but no, as far as I know it is drawn using platform-specific QStyle ControlElement and SubElement types because it is not based on QGraphicsItem.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 9
    Last Post: 28th February 2015, 20:58
  2. data base in qt
    By Fafa in forum Qt Programming
    Replies: 2
    Last Post: 15th June 2011, 01:52
  3. How to get the base parent Widget
    By vaibhav in forum Qt Programming
    Replies: 8
    Last Post: 15th February 2011, 12:27
  4. MVC - Abstract Widget Base Class - setupUI
    By SenSej in forum Newbie
    Replies: 0
    Last Post: 13th October 2008, 11:44
  5. very very base question
    By mickey in forum General Programming
    Replies: 12
    Last Post: 26th March 2008, 23:01

Tags for this Thread

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.