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. Align icon on a tab (QTabWidget) & tab widths
Forum Updated to NodeBB v4.3 + New Features

Align icon on a tab (QTabWidget) & tab widths

Scheduled Pinned Locked Moved General and Desktop
8 Posts 1 Posters 10.2k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tineu
    wrote on last edited by
    #1

    Defaut is left aligned. Cannot change this through style sheets - I want it center aligned. Is there any sample code for this?

    Can each (individual) tab size be changed (width)?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      by default the icon and text are center aligned. remove text and see if the icon comes to the left or center.

      bq. Can each (individual) tab size be changed (width)?

      do you mean tab headers or varying width with individual tab pages

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tineu
        wrote on last edited by
        #3

        I don't have any text. Only icons which are definately left aligned (Qt4.6). I added the icons in QtCreator UI and in code, same thing. In style sheets there are no alignments.

        Width: Individial tab (with an icon in it). If I set the width of the icon, every tab width changes to the same value. For instance: If there are 5 tabs - each 20px wide. If width of any tab is changed, all tabs reset to the same width.

        edit:

        To demonstrate I've created a new project with QTabWidget and one icon (no style sheets or aditional code)

        "http://i38.tinypic.com/zj8pll.jpg":http://i38.tinypic.com/zj8pll.jpg

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          try something like this,

          extend tab widget, and in the QTabBar, call setTabButton on individual index, with your custom widget

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tineu
            wrote on last edited by
            #5

            If I understand correctly you are saying I should subclass QTabWidget so I have access to the tabBar, then create a custom widget (ie QLabel static casted to button) and add it through "setTabButton"?

            Either way I'm quite new at Qt - could you help me out with a sample code maybe? I'd appriciate it.

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              ok sure, but might take sometime as am busy with few other things too :)

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tineu
                wrote on last edited by
                #7

                As I stated - any help is appriciated. Thank you in advance.

                1 Reply Last reply
                0
                • ? This user is from outside of this forum
                  ? This user is from outside of this forum
                  Guest
                  wrote on last edited by
                  #8

                  I put up something quickly "here":http://developer.qt.nokia.com/wiki/CustomTabBar, with just one tab button, but something you can extend upon.. is this what you wanted?

                  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