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. Change tab widget - no tab content / page
Forum Updated to NodeBB v4.3 + New Features

Change tab widget - no tab content / page

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 4.9k 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.
  • P Offline
    P Offline
    ProgramistaQtC
    wrote on last edited by
    #1

    Hi
    I would like to change the widget of one of my tabs in QTabWidget like in gtkD:
    http://api.gtkd.org/src/gtk/Notebook.html
    I mean to put whatever e.g. QPushButton instead of label in tab.

    I know about function:
    void QTabBar setTabButton ( int index, ButtonPosition position, QWidget *widget …),
    but I would like to make my widget was the only one in the my tab and to be centered in it - not aligned to the left or right

    Can I do it in C++/Qt?

    Sorry for my English

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      If you use the layout system Qt provides, you will be able to center your widget.

      Also, you can add and remove widgets from layouts dynamically through code, so that's how your going to want to replace your QLabel with the QPushButton.

      If your in the designer, you can right click on your tab pane, and select the desired layout / add spacers to center your widget / etc.

      Have a look at:
      http://qt-project.org/doc/qt-4.8/layout.html

      1 Reply Last reply
      0
      • P Offline
        P Offline
        ProgramistaQtC
        wrote on last edited by
        #3

        I do not know if you understand my question.
        I know about layouts etc.
        For eg. application with QTabWidget ( fan-ascii-art ):
        "http://oi43.tinypic.com/dfg2ue.jpg":http://oi43.tinypic.com/dfg2ue.jpg
        In gtkD I can change label "Tab 1" with widget which I choose.
        I do not want to change "CONTENT" - I know how do that.
        In gtkD that function is:
        void setTabLabel (Widget child, Widget tabLabel);
        The child is "CONTENT" and tabLabel is "Tab 1".
        Can I do that in C++/Qt?

        Thanks for your time.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          You can use:
          @int QTabWidget::addTab ( QWidget * page, const QIcon & icon, const QString & label )@
          and add any widget as you wish.
          In other way, you need layouts.

          1 Reply Last reply
          0
          • JeroentjehomeJ Offline
            JeroentjehomeJ Offline
            Jeroentjehome
            wrote on last edited by
            #5

            euh, use the tabwidget->setTabText()

            Greetz, Jeroen

            1 Reply Last reply
            0
            • P Offline
              P Offline
              ProgramistaQtC
              wrote on last edited by
              #6

              Sorry, but you do not understand.
              I am not surprised because I search for that function in QTabBar and QTabWidget classes many times.
              I know how to change "CONTENT" ( see image ) / tab page.
              "euh, use the tabwidget->setTabText()" - no, it's only change text in label.
              I would like to change that tab label with widget which I choose.
              In gtkD I can change both: tab label text, tab label and tab page.
              In Qt I found only how to change tab label text and tab page.
              Please look at:
              "http://oi39.tinypic.com/j7xhe9.jpg":http://oi39.tinypic.com/j7xhe9.jpg
              On "Tab 2 - AFTER" is button with this text.
              This is only example.
              Can I do that in C++/Qt?
              Thanks for help and your time.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                Buckets
                wrote on last edited by
                #7

                So do you just want the last tab to be a button that does some function?

                If that is the case, why not just implement a your own TabWidget class that inherits from QTabWidget and add a clicked() signal. Then you could connect it to a function that would check the tab index, and do what you want from there.

                You could have it create a new tab, open a file, make a little robot dance, or take over the world (if you have the take over the world function working).

                ba ba ba
                ba na na na

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  ProgramistaQtC
                  wrote on last edited by
                  #8

                  Not only last tab.
                  It is only example BEFORE-AFTER.

                  clicked() signal ... - no, I want button in tab ( button only for example - may be any QWidget )
                  I used signals and slots in past - I some know about it.

                  I searched for similar function like in gtkD.
                  I do not found it, so implement own TabWidget is generally the only idea I have.

                  I would have to the button in tab by default or can change widget by function like in gtkD, but I do not have idea how to implement this in my class.

                  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