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. How to hide/show the widgets/interfaces
QtWS25 Last Chance

How to hide/show the widgets/interfaces

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

    Hi,
    I am trying to hide the window after some time using the below code, but the window is never shown .
    always i am getting the output as

    bq. Starting /home/user/untitled-build-desktop/untitled...
    Hiding....

    how to to hide/show the widgets.

    @
    #include <QtGui/QApplication>
    #include "mainwindow.h"

    MainWindow *mPtr;

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    MainWindow w;
    mPtr = &w;
    w.show();
    sleep(1);
    w.hidewin();
    

    return a.exec();

    }
    @

    @
    #include "mainwindow.h"
    #include <QDebug>
    extern MainWindow *mPtr;

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    }

    MainWindow::~MainWindow()
    {

    }
    void MainWindow::hidewin()
    {
    qDebug()<<"Hiding....";
    mPtr->hide();
    }

    @

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Add the hiding code, and the timer (use QTimer, not the sleep() function!) to your main window class. Currently, you are doing all this before the event loop is started (a.exec()).

      (Z(:^

      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