Results 1 to 1 of 1

Thread: Minimized qwdiget always restore to maximized state in Mac

  1. #1
    Join Date
    Nov 2014
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation Minimized qwdiget always restore to maximized state in Mac

    A simple widget demo with system tray menu enabled.

    Here I put 3 buttons in the widget: "max button", "min button" and "normal button"

    Clicking "max button" calls 'showMaximized()'
    Clicking "min button" calls 'showMinimized()'
    Clicking "normal button" calls 'showNormal()'

    All above 3 buttons works fine.

    I also add systray menu "restore".

    Clicking "restore" from systray icon will call 'shorNormal()'

    The following is the steps to reproduce my bug.

    #1. Run app

    #2. Click 'max button' and the widget will scaled to maximum

    #3. Click 'normal button' and the widget will scaled back to normal size

    #4. Click 'min button' and the widget will minimized to Dock

    #5. Click systray menu 'restore' and the widget will restored from the Dock. But at the same time, the restored widget is always be scaled to maximum. As expected, it should be restored to normal size.

    I attached my project here, hope someone could give some hints.


    #include "widget.h"
    #include "ui_widget.h"
    #include <QDebug>

    Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);

    connect(ui->maxButton, SIGNAL(clicked()), this, SLOT(onMax()));
    connect(ui->minButton, SIGNAL(clicked()), this, SLOT(onMin()));
    connect(ui->normalButton, SIGNAL(clicked()), this, SLOT(onNormal()));

    createTrayIcon();
    }

    Widget::~Widget()
    {
    delete ui;
    }

    void Widget:nMax()
    {
    showMaximized();
    }

    void Widget:nMin()
    {
    showMinimized();
    }

    void Widget:nNormal()
    {
    showNormal();
    }

    void Widget:nRestore()
    {
    showNormal();
    raise();
    activateWindow();
    }

    void Widget::createTrayIcon()
    {
    restoreAction = new QAction(this);
    restoreAction->setText("Restore");

    connect(restoreAction, SIGNAL(triggered()), this, SLOT(onRestore()));

    trayMenu = new QMenu(this);
    trayMenu->addAction(restoreAction);


    trayIcon = new QSystemTrayIcon(this);
    trayIcon->setIcon(QIcon("/Users/hynesg/offline.png"));
    trayIcon->setContextMenu(trayMenu);

    trayIcon->show();
    }
    Attached Files Attached Files

Similar Threads

  1. Save and restore maximized state
    By Kwakkie in forum Newbie
    Replies: 7
    Last Post: 25th June 2012, 09:51
  2. Replies: 0
    Last Post: 31st May 2012, 11:33
  3. QWdiget to QmainWindow
    By bollibompa in forum Newbie
    Replies: 3
    Last Post: 11th April 2011, 10:36
  4. Replies: 0
    Last Post: 19th December 2010, 17:03
  5. Replies: 5
    Last Post: 9th May 2007, 22:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.