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. Placing an object into a specific page of a QStackedWidget
Forum Updated to NodeBB v4.3 + New Features

Placing an object into a specific page of a QStackedWidget

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

    Hi. I've got quite a few widgets that I would like to place on a particular page of a QStackedWidget. However, I have been having trouble.

    Every time I switch to another page of the QStackedWidget and then pull back to the original page, the widgets are not displayed on the ui.

    This is how I created and set up the aforementioned widgets.

        QWidget *lineParent = ui->stackedWidget;
    
        QLabel *REEEEE = new QLabel(lineParent);
        REEEEE->setText("AHHHHHHHH");
        REEEEE->move(100,100);
    
        //Build the main line.
        QFrame *frontLine = new QFrame(lineParent);
        frontLine->setStyleSheet(markerStyle);
        frontLine->setGeometry(X, Y, SPLITLINEWIDTH, SPLITLINEHEIGHT);
        QString labelText = "Initial Temp";
    

    I have not been able to locate a function that specifically places the widget on any specific page of the QStackedWidget (I found insertWidget but that doesn't seem to have placed the widget in a visible place). I am not sure how to proceed. Please let me know if more information is required.

    jsulmJ 1 Reply Last reply
    0
    • Dummie1138D Dummie1138

      Hi. I've got quite a few widgets that I would like to place on a particular page of a QStackedWidget. However, I have been having trouble.

      Every time I switch to another page of the QStackedWidget and then pull back to the original page, the widgets are not displayed on the ui.

      This is how I created and set up the aforementioned widgets.

          QWidget *lineParent = ui->stackedWidget;
      
          QLabel *REEEEE = new QLabel(lineParent);
          REEEEE->setText("AHHHHHHHH");
          REEEEE->move(100,100);
      
          //Build the main line.
          QFrame *frontLine = new QFrame(lineParent);
          frontLine->setStyleSheet(markerStyle);
          frontLine->setGeometry(X, Y, SPLITLINEWIDTH, SPLITLINEHEIGHT);
          QString labelText = "Initial Temp";
      

      I have not been able to locate a function that specifically places the widget on any specific page of the QStackedWidget (I found insertWidget but that doesn't seem to have placed the widget in a visible place). I am not sure how to proceed. Please let me know if more information is required.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Dummie1138 said in Placing an object into a specific page of a QStackedWidget:

      QLabel *REEEEE = new QLabel(lineParent);

      This is not how QStackedWidget is used. Please take a look at documentation: https://doc.qt.io/qt-6/qstackedwidget.html
      There is a simple example which shows how to add widgets to different pages:

      QWidget *firstPageWidget = new QWidget;
      QWidget *secondPageWidget = new QWidget;
      QWidget *thirdPageWidget = new QWidget;
      
      QStackedWidget *stackedWidget = new QStackedWidget;
      stackedWidget->addWidget(firstPageWidget);
      stackedWidget->addWidget(secondPageWidget);
      stackedWidget->addWidget(thirdPageWidget);
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

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