Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qstackedwidget
    Log in to post

    • SOLVED How can I make my window(Widget) restart after switching to another window(Widget) in a QStackedWidget?
      General and Desktop • qt6 qobject cpp delete qstackedwidget • • BogdanR  

      8
      0
      Votes
      8
      Posts
      169
      Views

      Ok thanks! I think I understand what I have to do
    • UNSOLVED Does QStackedWidget processes all pages simultaneously?
      General and Desktop • gui qstackedwidget pages • • MarcoMon  

      2
      0
      Votes
      2
      Posts
      109
      Views

      Hi and welcome to devnet, QStackedWidget does not care nor handle what do the widgets inside it. What will not happen is UI updates but all the rest will. What you can do is disable these processing when the widgets are not visible if it makes sense.
    • UNSOLVED Memory vs effiency of QStackedWidget
      General and Desktop • memory qstackedwidget speed • • arjun98  

      2
      0
      Votes
      2
      Posts
      128
      Views

      Hi, This will depend on your widgets and what their content. It will also depend on the device that runs your application. But more seriously, unless you are under very high memory constraints you should allocate the widgets commonly used from the start and the ones that are less often used when they are needed.
    • SOLVED QStackedWidget and adding new QGraphicsView to its pages
      General and Desktop • qgraphicsview qgraphicsscene qstackedwidget • • newToQt26  

      7
      0
      Votes
      7
      Posts
      630
      Views

      @newToQt26 Hi Good to hear. :) If the user can add or delete layers, it's pretty important you make sure curScene/curView always points to something valid as else you get a nasty crash.
    • UNSOLVED Dynamic QWidget for QStackedWidget using ID
      General and Desktop • qwidget qstackedwidget • • hobbyProgrammer  

      8
      0
      Votes
      8
      Posts
      562
      Views

      @hobbyProgrammer I don't know what is going on here, but I note that for a given circuitID you do two new Circuit(circuitID)s, one in fillCircuitMenu() and another any time slot goToCircuit(int index) is invoked. I don't know if that is correct, no re-use of same Circuit instance? Separately, I don't think there is any need to use deprecated QSignalMapper any longer. You can replace with new signal/slot syntax (you should get away from SIGNAL/SLOT() macros in all new code) plus a lambda. See e.g. https://doc.qt.io/qt-5/qsignalmapper.html#details for an example of this.
    • SOLVED Edit variables from other widget of QStackedWidget
      General and Desktop • qwidget qstackedwidget • • hobbyProgrammer  

      14
      0
      Votes
      14
      Posts
      572
      Views

      @hobbyProgrammer Do you actually have event loop running when you emit the signal?
    • SOLVED QStackedWidget: How to check if the next widget should be shown
      General and Desktop • qstackedwidget qstackedwidgets • • hobbyProgrammer  

      25
      0
      Votes
      25
      Posts
      600
      Views

      Because this is getting out of hand: https://github.com/DeiVadder/LoginExample
    • UNSOLVED QStackedWidget with multiple classes
      General and Desktop • qstackedwidget qstackedwidgets • • hobbyProgrammer  

      2
      0
      Votes
      2
      Posts
      271
      Views

      Hi, You don't call show on your sw object and it's not part of your stacked widget.
    • UNSOLVED Problem size policy in QStackedWidget
      General and Desktop • qstackedwidget sizepolicy • • Loic B.  

      14
      0
      Votes
      14
      Posts
      3366
      Views

      You're correct and that's a good question. What version of Designer are you using ?
    • UNSOLVED Is changing a QWizard into a QStackedWidget the best option?
      General and Desktop • qt 4.8 qstackedwidget qwizard qt 4.8.5 • • roseicollis  

      12
      0
      Votes
      12
      Posts
      4210
      Views

      Hi Main windows is a bit special since it has "central widget". which there to allow to define areas around it for Dock windows. That is why we insert widget first. For all types of other widget we would insert directly. QWidget* centralWidget = new QWidget(); QVBoxLayout *layout = new QVBoxLayout; centralWidget->setLayout(layout); layout->addWidget(st); setCentralWidget(centralWidget); seems fine. For centralWidget , u can then use the Stacked. My mainWindow code actually looks like: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { setLayout(layout); // that sets directly on mainwin. not sure it does what we think. You can just single step and see the values to find out why u crash. Sorry, i cant spot it. Running it helps. I think u need a setCentral also. That is the reason no 2 to why i like UI file so much. no crashing as u can only insert legally when visually :) And no code to try to spot bugs in. I think u need new widget widget as central new layout layout to widget inset stacked to that layout and then the page stuff
    • SOLVED Trouble with QStackedWidget
      General and Desktop • qstackedwidget login constructor • • cxam  

      2
      0
      Votes
      2
      Posts
      823
      Views

      Hi, Since you marked it solved, can you share what you did to fix your code ?
    • UNSOLVED QStackedWidget setCurrentIndex slot not showing on Signals&Slots editor (QtCreator)
      General and Desktop • qtcreator signal & slot slot qstackedwidget • • cxam  

      15
      0
      Votes
      15
      Posts
      5553
      Views

      @mrjj Hi! I managed to make everything just as I wanted, everything is going fine. The code example you sent me really did the trick. Thanks a lot.
    • UNSOLVED Multiple ui form
      General and Desktop • qstackedwidget • • Gillou_beginqt  

      2
      0
      Votes
      2
      Posts
      806
      Views

      Hi, Silly short answer but: yes it is
    • SOLVED Tap into QWidget::create
      General and Desktop • widgets custom widget qstackedwidget notifications • • kshegunov  

      8
      0
      Votes
      8
      Posts
      2567
      Views

      @raven-worx Hello, Thanks for the code, but I know how to do the scheduling. I actually went with QPointer<QObject> since the QObject might be deleted while waiting in the event loop. Like this: bool AgDial::eventFilter(QObject * object, QEvent * event) { switch (event->type()) { case QEvent::ChildAdded: QMetaObject::invokeMethod(this, "scheduleChildAdd", Qt::QueuedConnection, Q_ARG(QPointer<QObject>, QPointer<QObject>(reinterpret_cast<QChildEvent *>(event)->child()))); break; case QEvent::ChildRemoved: d()->detachAction(reinterpret_cast<QChildEvent *>(event)->child()); break; } return QStackedWidget::eventFilter(object, event); } Thanks for taking the time though! Kind regards.
    • UNSOLVED qstackedwidget timeout
      General and Desktop • qstackedwidget • • WhatIf  

      6
      0
      Votes
      6
      Posts
      1516
      Views

      @WhatIf Hi Yes it was as i thought of. Even better actually as you found singleShot :) Only thing that I wondered was the singleShot(200) as 200 is very fast :)
    • UNSOLVED QStackedWidget unexpected behavior
      General and Desktop • qstackedwidget • • WhatIf  

      2
      0
      Votes
      2
      Posts
      481
      Views

      Hi yes its normal. You set the active page in Designer when you go to it. You can call ui->yourstackedwidget->setCurrentIndex(0) in QMainWindow constructor to make sure first page is always displayed.
    • SOLVED Buttons aren't showing
      General and Desktop • qtcreator qstackedwidget • • AlaaM  

      4
      0
      Votes
      4
      Posts
      1441
      Views

      @AlaaM Well , i did see it but button start in 0,0 perfect valid so did not think much about it. Just added + QString::number(i) so when testing by changing stackedWidget->setCurrentIndex(0); I could see it was indeed another button :)
    • QStackedWidget hiding pages
      General and Desktop • widgets qstackedwidget page • • stvokr  

      2
      0
      Votes
      2
      Posts
      1684
      Views

      My first thought is that QGroupBox probably provides a sizehint() that is zero if the widget is not visible where your other widget probably does not do this. The QStackedWidget would provide a sizehint() based on all of the children. When you hide the children you make the end result no smaller than the largest child. Another idea to implement this is to have a common set of options always visible and show/hide the additional parts that are unique to the 'multi' and 'other' views. This will autosize.
    • Switch to next page after login
      General and Desktop • database qstackedwidget qtsql navigation page layout • • salahuddin  

      2
      0
      Votes
      2
      Posts
      816
      Views

      Hi and welcome While using QStackedWidget for all pages / screens could work just fine, a more common design would/could be using QDialog for welcome and login and when closed - the main window for the graphs etc.
    • [SOLVED] How to access a slot from a different widget: If form1 clicks a button, form2 should respond.
      General and Desktop • layout qstackedwidget qstackedwidgets qstackedlayout • • Jorge  

      2
      0
      Votes
      2
      Posts
      854
      Views

      In case anyone wonders, I found the way to connect both classes and tell mainWidget to change stack through the login widget's button. //header of the login widget public slots: void verifyUser(int iUserCorrect ) { if ( iUserCorrect != iUserVerified ) { iUserVerified = iUserCorrect; emit valueChanged( iUserVerified ); } } signals: void valueChanged( int iUserCorrect ); private slots: void on_btnLogin_clicked(); private: Ui::QLogin *ui; QSqlDatabase sqlUsuarios; int iUserVerified; source file of the login widget (only where valueChanged was used, in the SQLite verification): iUserVerified = 0; QSqlQuery sqlQry; if(sqlQry.exec("SELECT User, Password, Role FROM Usuarios WHERE User=\'" + sUsername + "\' AND Password =\'" + sPassword + "\'")) { if(sqlQry.next()) { ui->lblStatus->setText("Nombre de usuario y contraseña válidos."); qDebug() << "Usuario OK"; verifyUser(1); } and finally, the connect() in the mainWidget source file. Note that I had already made an instance of a promoted login widget inside this file: #include "mainwidget.h" #include "ui_mainwidget.h" #include <qlogin.h> #include <QMessageBox> #include <QCalendarWidget> #include <QDebug> #include <QPushButton> mainWidget::mainWidget(QWidget *parent) : QWidget(parent), ui(new Ui::mainWidget) { mainLayout = new QVBoxLayout(); stackedLayout = new QStackedLayout(); QLogin *loginWidget = new QLogin; stackedLayout->addWidget(loginWidget); stackedLayout->addWidget(new QCalendarWidget); mainLayout->addLayout(stackedLayout); setLayout(mainLayout); connect(loginWidget, SIGNAL(valueChanged(int)), this, SLOT(changeStack())); ui->setupUi(this); } The changeStack method simply changes the index of the stack: void mainWidget::changeStack() { stackedLayout->setCurrentIndex(stackedLayout->currentIndex() + 1); qDebug() << "changeStack()"; } Took me some time, but I finally got it.
    • Using buttons from a QStackedLayout main widget in the current widget
      General and Desktop • qstackedwidget qstackedwidgets qstackedlayout • • Jorge  

      4
      0
      Votes
      4
      Posts
      1160
      Views

      It really depends on your application. One thing to keep in mind is that these buttons should not know what's in e.g. your login widget. They should be enabled when appropriate. Otherwise you are going to have a pretty hard to maintain widget there if you add more "pages".
    • [SOLVED] QAction To Toggle QWidget
      General and Desktop • c++ qt5 slots qstackedwidget toggle • • Adept  

      7
      0
      Votes
      7
      Posts
      2194
      Views

      You could also simplify this a little: void MainWindow::menuToggled() { auto widget = (container->currentWidget() == menuWidget) ? mdiContainer : menuWidget; container->setCurrentwidget(widget); }