Results 1 to 8 of 8

Thread: Some questions about custom drawing for QTabWidget/QTabBar

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Some questions about custom drawing for QTabWidget/QTabBar

    I have a QTabWidget with tabs which are created and removed dynamically depending upon what option user selects. Now, first thing i need to do is to achieve a look for the tabs as per the attached screenshot (tabs.jpg). So, as per the screenshot, the selected tab is blue and the other tabs are black. Also, the non-selected tabs have a different arrow-like shape.
    Here's how i think i can do it:

    1) Use stylesheet to set the background of the tabs. I am not sure if this will work properly and upto the desired level of look and feel. Also, in this case, the actual tabs will still be rectangular so it would be a problem.
    2) Subclass the QTabBar and draw the tabs myself in paint() method. For this i think i can do either of the following in paint() method:

    a) Set the background image for selected and de-selected tabs and use setMask to mask the widget i.e. tabs based on the image shape. So, this way i should get the non-rectangular shape for non-selected tabs.
    b) Draw the non-rectangular shape myself and set the background image or color.

    Please let me know your thoughts on this. Which approach is feasible or is any any other solution?
    Attached Images Attached Images

Similar Threads

  1. Drawing standard widgets using a custom paint engine
    By Waywocket in forum Qt Programming
    Replies: 26
    Last Post: 21st October 2010, 20:40
  2. Replies: 1
    Last Post: 3rd November 2009, 22:26
  3. Replies: 0
    Last Post: 10th October 2009, 05:44
  4. custom QColumnView, some questions
    By Mystical Groovy in forum Qt Programming
    Replies: 1
    Last Post: 9th October 2009, 14:03
  5. Some questions about custom style
    By charlse in forum Qt Programming
    Replies: 0
    Last Post: 2nd April 2009, 09:54

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.