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. [SOLVED] shortcut to mainwindow methods
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] shortcut to mainwindow methods

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.0k 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.
  • K Offline
    K Offline
    kalster
    wrote on last edited by
    #1

    question 1:
    this->isMinimized(); is not minimizing the window.

    question 2:
    I would like to use a shortcut for the mainwindow method calling but i don't know how to do that.
    @MainWindow *w = new MainWindow();@
    or
    @Mainwindow w@
    in the mainwindow.cpp file, when i run the above 2 code, the exe is not created but i do not get an error. is there a shortcut to call MainWindow.Show(); I would like to use w.show{}; instead.

    Mainwindow.cpp
    @#include "mainwindow.h"
    #include "ui_mainwindow.h"

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

    MainWindow::~MainWindow()
    {
    delete ui;
    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      hi,

      first of all, isMinimized returns, whether the window is minimized or not, if you want to minimize it, use showMinimized.

      Second, I don't understand your question about shortcut. What exactly do you mean by that? Where should it be used?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kalster
        wrote on last edited by
        #3

        just below the following code is where i would like the short cut to the mainwindow method
        @ui->setupUi(this);@

        so it would look like this...
        @ui->setupUi(this);
        MainWindow *w = new MainWindow();@
        or
        @ui->setupUi(this);
        MainWindow w;@

        instead of typing MainWindow. all i type is w but when i type w in the mainwindow.cpp i don't get a list of methods to choose from. the exe is created but does not load up and i get no errors.

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          You are the main window. so this would reference the main window. A shortcut is something you put on the desktop :-)

          With your code you create a new MainWindow, so a second one. This is basic C++ and Object orientation.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kalster
            wrote on last edited by
            #5

            thank you Gerolf. that makes since. no more desktop shortcuts for me :)

            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