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. [Solved]creating tabs
Forum Updated to NodeBB v4.3 + New Features

[Solved]creating tabs

Scheduled Pinned Locked Moved Mobile and Embedded
48 Posts 5 Posters 25.4k 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.
  • EddyE Offline
    EddyE Offline
    Eddy
    wrote on last edited by
    #36

    I think I don’t understand what you want exactly, maybe you could show us an image of your form ?

    Qt Certified Specialist
    www.edalsolutions.be

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

      Rather than creating a new thread I thought its better this way,

      @

      tabWidget->setTabIcon(0,QIcon(":images\clock.png"));

      @

      The above code should set an icon in the first tab right?? But apparently its not!. I've put the image in the resource file.
      ???

      any idea

      alfah

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

        I think you missed a ""

        Try this :
        @tabWidget->setTabIcon(0,QIcon(":\images\clock.png")); @

        Qt Certified Specialist
        www.edalsolutions.be

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

          '' did not do the trick :(

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

            @tabWidget->setTabIcon(0,QIcon(":/images/clock.png")); @

            works for me on the simulator.

            the / or \ depends on your OS

            Qt Certified Specialist
            www.edalsolutions.be

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

              ahhh, , its not workin on the simulator or the device!!

              it is '/'. And i have corrected it. But still it does not work. Does image size gotta do anything with it??
              ive used 16x16. its almost 900 byte

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

                you can test if it's available from the resource editor using a dialog in Qt Designer and set the icon from there.

                Qt Certified Specialist
                www.edalsolutions.be

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

                  Ive pulled in a tabWidget in the Designer. But i can only find iconsize property not the simple icon property with which you can set.

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

                    no you have to use code to add it to a tab.

                    But you could use a QLabel just for testing if the icon is reachable through the resource editor.

                    Qt Certified Specialist
                    www.edalsolutions.be

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

                      it worked in the new project, both in the device as well as the simulator.
                      @
                      ui->tabWidget->setTabIcon(0,QIcon(":/images/clock.png"));
                      @

                      I think i know why it doesn work on my application.
                      @
                      tabWidget = new QTabWidget;
                      tabWidget->setStyleSheet("QTabWidget::tab-bar{left:0px; width:350px; }\n"
                      "QTabBar::tab{height:40px; width:95px; color:red; font:9pt; }\n");
                      tabWidget->setTabIcon(0,QIcon(":/images/clock.png"));

                      pCalender = new QWidget;
                      pHistory = new QWidget;
                      pStatistics= new QWidget;

                      connect(tabWidget,SIGNAL(currentChanged(int)),this,SLOT(onSelectTab(int)));
                      tabWidget->addTab(pCalender,tr("Calender"));
                      tabWidget->addTab(pHistory,tr("History"));
                      tabWidget->addTab(pStatistics,tr("Statistics"));
                      tabWidget->setTabIcon(0,QIcon(":/images/clock.png"));
                      @

                      EDIT : solved :D

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

                        bq. it worked in the new project, both in the device as well as the simulator.

                        so you know a good approach to solve issues yourself. Sometimes a project can grow bigger and bigger. If you make a small test project like you did you can easily narrow down to the problem. Now you know for sure that the code is right.

                        bq. EDIT: na i don think so, cuz widgets are placed inside the tabs not on those heading.

                        To be sure just comment out the lines you suspect. This one is for you ;)

                        Qt Certified Specialist
                        www.edalsolutions.be

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

                          ok all advises noticed and acknowledged :)

                          I have solved it too,

                          I jus needed to place the same code after the addTab function(), :) How dumb of me! How else would it put an icon if the tab not added :D :D

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

                            Glad you solved it! You even start helping out others.

                            Keep up the good work!

                            Qt Certified Specialist
                            www.edalsolutions.be

                            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