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. Combining QTabWidget und QStackedWidget at runtime
Forum Updated to NodeBB v4.3 + New Features

Combining QTabWidget und QStackedWidget at runtime

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 353 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
    andi456
    wrote on last edited by andi456
    #1

    Hi,

    as some of the tabs of my QTabWidget instance will only be needed if certain conditions in a configuration file are met, I would like to be able to show a html page after a click on a QTableView cell in the optional tabs as well.

    I got it to work with the help of the code generated by QtCreator, that I try to make use of for the optional tabs as well. But unfortunately nothing shows up in the corresponding tabs.

    For the optional tab (I confined myself to one for testing) I did the following

    baseWidget = new QWidget();
    stackedWidget = new QStackedWidget(baseWidget);
    contentWidget = new QWidget(baseWidget);
    tview = new QTableView(contentWidget);
    

    Finally I added the baseWidget to the QTabWidget instance and the contentWidget as well as Widget for the html to the QStackedwidget instance.

    But, as I said, nothing is showing up, when I enter the corresponding tab.

    What may be the cause of this behaviour?

    Kind regards,

    Andreas

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

      Hi,

      In fact you are just parenting widgets one to the other. That does not mean they will be shown.

      You should simply build the widgets that should be shown in the stack, add them to your QStackedWidget and then add the stacked widget as new tab to your QTabWidget.

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

      A 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        In fact you are just parenting widgets one to the other. That does not mean they will be shown.

        You should simply build the widgets that should be shown in the stack, add them to your QStackedWidget and then add the stacked widget as new tab to your QTabWidget.

        A Offline
        A Offline
        andi456
        wrote on last edited by
        #3

        @SGaist Ok, I'll try that.

        Btw., I figured out that the widgets are not visible by default and cannot be influenced by setVisible(true).

        SGaistS 1 Reply Last reply
        0
        • A andi456

          @SGaist Ok, I'll try that.

          Btw., I figured out that the widgets are not visible by default and cannot be influenced by setVisible(true).

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @andi456 depending on what you want to achieve, you should also check the layout management chapter. That will simplify things.

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

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            @andi456 depending on what you want to achieve, you should also check the layout management chapter. That will simplify things.

            A Offline
            A Offline
            andi456
            wrote on last edited by
            #5

            @SGaist Thank you. I really only had to change one line of code and now it works, i.e., instead of the QWidget instance (baseWidget) I had to add the QStackedWidget instance to the QTabWidget.

            1 Reply Last reply
            1
            • A andi456 has marked this topic as solved on

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved