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. [SOLVED] Overlap two widget
QtWS25 Last Chance

[SOLVED] Overlap two widget

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.5k Views
  • 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.
  • X Offline
    X Offline
    XelaG
    wrote on last edited by
    #1

    Hello,

    I would like to create this kind of window.
    I use a QTabWidget customized using StyleSheet so I managed to add a space between the first and the second tabs, Now, I would like to put some QPushButton between those tabs.

    Since the central widget is setup as a vertical layout I don't know how to add three QPushButton that overlap the QTabWidget and that do not stand below the QTabWidget.

    Does anyone know how to perform this ?

    !http://i61.tinypic.com/2ikusew.png!

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Just an idea but you could use QTabBar::setTabButton with a custom widget containing your buttons.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You'll have to position them manually. I'd create a container widget that contains the buttons (and manages them in a horizontal layout or even just use a QToolBar), and give that container the tab widget as its parent (without using a layout to manage its geometry). Then, use an event filter on the tab widget to position the button container in case of resizes and moves.

        It looks like you're trying to re-create some sort of ribbon like UI. If so, you could also consider using DevMachines QTitanRibbon component.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          XelaG
          wrote on last edited by
          #4

          [quote author="SGaist" date="1391200102"]Just an idea but you could use QTabBar::setTabButton with a custom widget containing your buttons.
          [/quote]

          I haven't thought about this trick. I'll try it.

          [quote author="Andre" date="1391282276"]You'll have to position them manually. I'd create a container widget that contains the buttons (and manages them in a horizontal layout or even just use a QToolBar), and give that container the tab widget as its parent (without using a layout to manage its geometry). Then, use an event filter on the tab widget to position the button container in case of resizes and moves.[/quote]

          If SGaist's trick doesn't work I'll try yours.

          [quote author="Andre" date="1391282276"]It looks like you're trying to re-create some sort of ribbon like UI. If so, you could also consider using DevMachines QTitanRibbon component. [/quote]

          I'm aware of QTitanRibbon but I'm deveopping a personal project I won't sell, maybe it will be open source so I don't want to spend 500$ in a component. But thanks for the idea.

          "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

          1 Reply Last reply
          0
          • X Offline
            X Offline
            XelaG
            wrote on last edited by
            #5

            [quote author="SGaist" date="1391200102"]Just an idea but you could use QTabBar::setTabButton with a custom widget containing your buttons.[/quote]

            I've tried your solution, it almost works but it's not perfect.
            I've created a widget container with two QPushButton in it. I've associated it to the second tab and it worked. But now, I would like to set the style for the second tab only so it won't have border but I can't cause using the stylesheet I can define styles for QTabBar::tab::first, QTabBar::tab::middle, QTabBar::tab::last or QTabBar::tab::selected but not the a specific tab.

            "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

            1 Reply Last reply
            0
            • X Offline
              X Offline
              XelaG
              wrote on last edited by
              #6

              It works.
              Andre's solution is the simplest way to do that.

              Here the code.
              @ui->widget->setParent( ui->tabWidget );
              ui->widget->setGeometry( QRect(64, 0, 84, 28) );@

              The image below shows the result.
              Thanks guys for your help.

              !http://s3.postimg.org/aic0l6gur/Untitled.png!

              "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                Glad to see its working for you. One small tip: it would be wise to use more descriptive names than "widget" for your objects. That makes your code easier to read back later on. Remember, you'll write code once, but will read it at least about a dozen times later one. Its worth making that reading as easy as possible.

                1 Reply Last reply
                0
                • X Offline
                  X Offline
                  XelaG
                  wrote on last edited by
                  #8

                  [quote author="Andre" date="1391419136"]Glad to see its working for you. One small tip: it would be wise to use more descriptive names than "widget" for your objects. That makes your code easier to read back later on. Remember, you'll write code once, but will read it at least about a dozen times later one. Its worth making that reading as easy as possible.[/quote]

                  It's actually what I do in my final project, I name the variables using a prefix such as (int iValue, unsigned short usCounter), here is just a sample app I won't use it in the release version. I never test big tricks in the final project to not insert bugs it if I finally decide to remove the test part.

                  "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding

                  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