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. Overlapping frame (or widget) ?

Overlapping frame (or widget) ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 823 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.
  • C Offline
    C Offline
    ciclonite
    wrote on last edited by
    #1

    Hi,
    sorry for noob question.
    I've two frame with the same size and position (overlapped). On frame_1 there is a button called btn1 . On frame_2 there is another button called btn2.
    I want to achieve this result:
    When a user click on btn1 (the frame on top) , the frame_1 disappear and frame_2 appear. When a user click on btn2 the frame_2 disappear and frame_1 appear.
    Can i achieve this result with frame or widget? ( I've tried with setVisible function without success).
    Thanks, Giovanni.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Sounds like a job for QStackedWidget:

      QStackedWidget* foo = new QStackedWidget();
      foo->addWidget(frame_1);
      foo->addWidget(frame_2);
      connect(frame_1->btn1, &QPushButton::clicked, [=]{ foo->setCurrentIndex(1); });
      connect(frame_2->btn2, &QPushButton::clicked, [=]{ foo->setCurrentIndex(0); });
      
      1 Reply Last reply
      0
      • C Offline
        C Offline
        ciclonite
        wrote on last edited by
        #3

        @Chris-Kawa said:

        nect(fra
        Thanks a lot Chris, very clean solution!
        I've found that the issue was with the designer. When i put one widget over another the designer puts the first widget inside the second. I will a try your solution that sound a lot better.
        Thanks again.
        Giovanni.

        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