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. Looking for advice on how to make one widget be displayed over another
QtWS25 Last Chance

Looking for advice on how to make one widget be displayed over another

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 20.3k 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.
  • T Offline
    T Offline
    TwoGunBerg
    wrote on last edited by
    #1

    Hi All;

    here is my dilema. I am displaying a picture in a widget called PictureLabel that has been derived from QLabel, after the user chooses which to display. the derived PictureLabel's sole purpose is to be able to have a clicked signal. when the PictureLabel is clicked i want to have a widget with information on the picture to appear super imposed over the Picture that is being displayed. i have all the classes set to go but i'm having a problem trying to figure out how to have the info appear.

    The basic layout i have is a QVBoxlayout that contains the PictureLabel and a menucontroller widget. The menucontroller contains a QHBoxlayout that has an albummenu, a picturemenu and a QPushButon ( the QPushButton is only visible when Picturemenu is visible). When the user selects an album from the album menu, it disappears and the picture menu will appear with images from the selected album.

    any ideas?

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      When you add 2 widgets at the same position (overlap), the second one has a higher z-order and comes on top of the first. Based on your logic you can then use show() or hide() calls to make a specific widget appear or disappear. Would that solve your problem?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DenisKormalev
        wrote on last edited by
        #3

        Maybe QStackedLayout will help you?

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          cool@Denis :)

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TwoGunBerg
            wrote on last edited by
            #5

            chetankjain Wrote:

            "When you add 2 widgets at the same position (overlap), the second one has a higher z-order and comes on top of the first. Based on your logic you can then use show() or hide() calls to make a specific widget appear or disappear. Would that solve your problem"

            How do add two widgets to the same position when you are using a QVBoxlayout? doesn't a QVBoxlayout by nature put each widget added at a different position?

            Denis Kormalev wrote:

            "Maybe QStackedLayout will help you?"

            I thought about that but unfortunately only one of the stacked panes can be shown at a time and i need to have the picture showing below the infowidget when it pops up. The infowidget will be smaller than the picture displayed.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              TwoGunBerg
              wrote on last edited by
              #6

              Here is the layout of the gui if it helps. I also have a question on handling resizing of the gui which i will ask later.

              !http://i1209.photobucket.com/albums/cc384/seckley/Drawing1.jpg(Gui layout)!

              1 Reply Last reply
              0
              • ? This user is from outside of this forum
                ? This user is from outside of this forum
                Guest
                wrote on last edited by
                #7

                [quote author="TwoGunBerg" date="1284555514"]How do add two widgets to the same position when you are using a QVBoxlayout? doesn't a QVBoxlayout by nature put each widget added at a different position?
                [/quote]

                You can set the second one as the child of the first anytime. This code shows how to do it.. would that solve your problem?

                @
                QVBoxLayout *vboxlayout = new QVBoxLayout;
                ui->frame->setLayout(vboxlayout);

                // lbl occupies whole frame
                QLabel *lbl = new QLabel("Picture Label!");
                vboxlayout->addWidget(lbl);
                
                // lbltop is the child of lbl
                QLabel *lbltop = new QLabel("Picture Info Label!", lbl);
                lbltop->setGeometry(50,50,50,50);
                lbltop->show();
                
                qDebug() << "Picture Label: " << lbl->rect() << ", " << lbl->size();
                qDebug() << "Picture Info Label: " << lbltop->pos();
                

                @

                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