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] [N00b] Need tips on creating UI
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] [N00b] Need tips on creating UI

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.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.
  • V Offline
    V Offline
    valandil211
    wrote on last edited by
    #1

    Hello Qt Devs!

    I am developing a front-end to a PostgreSQL DB. I have some ideas for the design of the UI, but have no idea on how to implement them. Here isi the situation.

    I have QMainWindow with Menu Bar. I want to have specific content appear in the MainWindow when I press some button in the Menu Bar.

    For instance, when I press "Start QA Instance", I have some widgets to appear below the menu bar. However, when I press on "Employee List", I want the widgets of "Start QA Instance" to disappear and have the widgets pertaining to "Employee List" to appear. Anyway to do that?

    Thanks,

    Joey Dumont

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Using "signals and slots":http://doc.qt.nokia.com/4.7/signalsandslots.html you can control events. Use "QWidget":http://doc.qt.nokia.com/latest/qwidget.html methods setVisible(), show(), hide() to control the visibility of your widgets.

      Cheers,
      Leon

      http://anavi.org/

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        Create a QWidget subclass, which might contain any other widgets using Q*Layout and QWidget::setLayout(), for every set of widgets you want to display and add it to a QStackedWidget which becomes the central widget.

        Now you can freely switch betweens those "widget sets" using QStackedWidget::setCurrentIndex() or QStackedWidget::setCurrentWidget().

        1 Reply Last reply
        0
        • S Offline
          S Offline
          solareclectic
          wrote on last edited by
          #4

          For cases where I have fewer than 6 or 8 sets of "some widgets" that I switch between, I tend to use a QTabWidget.

          Many more than that, then I use QStackedWidget, and switch between the pages with QComboBox. It is easy to connect the QComboBox's currentIndexChanged(int) signal to the QStackedWidget's setCurrentIndex(int) slot using the Designer, or simply your QMainWindow's constructor.

          Or, if I have plenty of room and will be switching frequently between sets of widgets, I'll put a QListWidget (QListView is usually too heavy for this) alongside and make the same connection as I would for the QComboBox.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            valandil211
            wrote on last edited by
            #5

            Thanks for the tips!

            Joey Dumont

            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