Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to make tabs expanding???
Forum Updated to NodeBB v4.3 + New Features

How to make tabs expanding???

Scheduled Pinned Locked Moved Mobile and Embedded
32 Posts 3 Posters 24.0k 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.
  • A Offline
    A Offline
    alfah
    wrote on last edited by
    #1

    hey everybody,

    How can I make the tabs expanding?. I was able to set size of the tabs with the following
    @
    tabWidget->setStyleSheet("QTabBar::tab{height:40px; width:108px; color:red;font: 9pt}");
    @
    but there is a small gap between the left end of the screen and the first tab, how ever the third tab touches the right end. I jus want all the three tabs to be fully expanded to the screen size.
    If i increase the width to more than 108px, the tab width with increases and two scroll buttons appear at both ends. No i dont want that.

    The second problem is that i cant align the tabs to the centre. If I get the solution for the first problem, I would not be needing to align the tabs to the center since it will be expanded to the screen size.
    Though i found a solution like this, it does not work :(

    @
    QTabWidget::tab-bar { alignment: center; }
    @

    I tried to set it like this in my code
    @

    tabWidget->setStyleSheet("QTabWidget::tab-bar{alignment:center; }");
    @

    alfah

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MichK
      wrote on last edited by
      #2

      Maybe you are resetting your style sheet instead of adding new style.

      @
      tabWidget->setStyleSheet("QTabWidget::tab-bar{alignment:center; }\n"
      "QTabBar::tab{height:40px; width:108px; color:red;font: 9pt}\n"
      );
      @

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #3

        Hi alfah,

        for your first question try this :

        @ QTabWidget::tab-bar {
        left: 0px; /* move to the right by 0px */
        }@

        As I understand if this is fixed the second problem dissappears?

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alfah
          wrote on last edited by
          #4

          eddy,

          no the problem is not solved with that,
          infact,

          @
          tabWidget->setStyleSheet("QTabBar::tab{height:40px; width:108px; color:red;font: 9pt}");
          tabWidget->setStyleSheet("QTabWidget::tab-bar{left:0px; }");
          @
          i tried like this, my first stylesheet setting disappeared!! no color red or size specificcation.

          yea solving this would dissolve the second problem :)

          alfah

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alfah
            wrote on last edited by
            #5

            michal,

            I tried your solution, the setting font and ht and width works, but it does not align to the centre :(

            alfah

            1 Reply Last reply
            0
            • A Offline
              A Offline
              alfah
              wrote on last edited by
              #6

              i tried this too ,
              it does not work

              @
              tabWidget->setSizePolicy(QSizePolicy::Expanding);
              @

              it gives some error that QSizePolicy is private!

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                [quote author="alfah" date="1312960820"]eddy, no the problem is not solved with that, infact, @ tabWidget->setStyleSheet("QTabBar::tab{height:40px; width:108px; color:red;font: 9pt}"); tabWidget->setStyleSheet("QTabWidget::tab-bar{left:0px; }"); @ i tried like this, my first stylesheet setting disappeared!! no color red or size specificcation. yea solving this would dissolve the second problem :) alfah[/quote]

                i tried it out with my code and it works on my example.

                I tried your code in Qt Designer RIGHT MOUSE BUTTON click > change style sheet. You get immediately a statusbar which tells you if the stylesheet is ok or not. I suggest you to test them always there. That's what I did and it gave me the following good result :

                @QTabBar::tab{height:40px; width:108px; color:red;font: 9pt;}
                QTabWidget::tab-bar{left:0px; }@

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  alfah
                  wrote on last edited by
                  #8

                  i jus found out something!!!!

                  both, yours and michal's code works in the simulator but not on the device!!!!! :(
                  now wat do i do??? :( :(

                  alfah

                  1 Reply Last reply
                  0
                  • EddyE Offline
                    EddyE Offline
                    Eddy
                    wrote on last edited by
                    #9

                    What device are you using? what target do you use on Qt Creator?

                    Qt Certified Specialist
                    www.edalsolutions.be

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      alfah
                      wrote on last edited by
                      #10

                      Im using a C7, and wat do you mean by target on Qt Creator? :(

                      1 Reply Last reply
                      0
                      • EddyE Offline
                        EddyE Offline
                        Eddy
                        wrote on last edited by
                        #11

                        So it's Symbian^3. That's what you use in the project settings in Qt Creator or choosing as template when starting your project.

                        Could you make a new Symbian^3 based project use a QWidget instead of a QMainWindow and apply a QTabWidget on it with your stylesheet? I want to diagnose when this occurs and maybe QMainWindow has to follow some styling rules.

                        Qt Certified Specialist
                        www.edalsolutions.be

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          alfah
                          wrote on last edited by
                          #12

                          i jus simply pasted the same code in another a new proj, new form of QWidget and i got the proj running with no errors but no tabs seen!!

                          I cant set the following

                          @
                          centralWidget()->setLayout(mainLayout);
                          @

                          I faced with the same prob last time and the above code did it, but now since it is QWidget. .:(

                          1 Reply Last reply
                          0
                          • EddyE Offline
                            EddyE Offline
                            Eddy
                            wrote on last edited by
                            #13

                            you cannot use centralWidget in a QWidget. just use setlayout in the constructor.

                            Qt Certified Specialist
                            www.edalsolutions.be

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              alfah
                              wrote on last edited by
                              #14

                              eddy,
                              got the tabs displayed, but the same trouble. It works on the simulator but not on the device!! :(
                              The gap is still there :(

                              1 Reply Last reply
                              0
                              • EddyE Offline
                                EddyE Offline
                                Eddy
                                wrote on last edited by
                                #15

                                [quote author="alfah" date="1312970956"]eddy, got the tabs displayed, but the same trouble. It works on the simulator but not on the device!! :( The gap is still there :([/quote]

                                Do you have any stylesheet changed on the device or is it like you didn't use a stylesheet at all?

                                Qt Certified Specialist
                                www.edalsolutions.be

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  alfah
                                  wrote on last edited by
                                  #16

                                  stylesheet changed on the device meaning??
                                  I havnt made any settings change.

                                  Simply created three tabs using following code
                                  @

                                  {
                                  ui->setupUi(this);
                                  QTabWidget *tabWidget = new QTabWidget;
                                  tabWidget->setStyleSheet("QTabWidget::tab-bar{left:0px; }\n"
                                  "QTabBar::tab{height:40px; width:105px; color:red;font: 9pt}\n");

                                  QWidget *pCalender = new QWidget;
                                  QWidget *pHistory = new QWidget;
                                  QWidget *pStatistics= new QWidget;
                                  
                                  pCalender->setStyleSheet("background-color: rgb(224, 220, 201);");
                                  pHistory->setStyleSheet("background-color: rgb(224, 220, 201);");
                                  pStatistics->setStyleSheet("background-color: rgb(224, 220, 201);");
                                  tabWidget->addTab(pCalender,tr("Calender"));
                                  tabWidget->addTab(pHistory,tr("History"));
                                  tabWidget->addTab(pStatistics,tr("Statistics"));
                                  mainLayout = new QVBoxLayout;
                                  mainLayout->addWidget(tabWidget);
                                  setLayout(mainLayout);
                                  

                                  @

                                  Only the above stylesheet has been used

                                  alfah

                                  1 Reply Last reply
                                  0
                                  • EddyE Offline
                                    EddyE Offline
                                    Eddy
                                    wrote on last edited by
                                    #17

                                    does this line
                                    @pCalender->setStyleSheet("background-color: rgb(224, 220, 201);"); @
                                    effectively do something on your device or is it the same as you didn't use it all?

                                    Qt Certified Specialist
                                    www.edalsolutions.be

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      alfah
                                      wrote on last edited by
                                      #18

                                      yes yeaa,

                                      Its totally needed. It is to set the background of the calender layout, otherwise the whole background turns black.

                                      1 Reply Last reply
                                      0
                                      • EddyE Offline
                                        EddyE Offline
                                        Eddy
                                        wrote on last edited by
                                        #19

                                        can you show me a printscreen of your widget?

                                        i want to know if your color is set on the application on your device.

                                        Qt Certified Specialist
                                        www.edalsolutions.be

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          alfah
                                          wrote on last edited by
                                          #20

                                          i found out somethin else too,

                                          In the simulator, if you use Maemo Fremantle, tabs are aligned center or pushed to the left. But if nokia symbian^3 simulator is used, the same problem occurs, the tabs are placed a bit off from the screen's left end.

                                          P.S printscreen of the simulator??

                                          alfah

                                          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