Linux qt creator консоль

How to run Qtcreator from terminal in Ubuntu?

Hi I have QtInstalled with the official qt installer (I haven’t used the package with the name «qtcreator»). I need to run QtCreator from terminal but I can’t locate the executable. I’m using Ubuntu 16.04.

@Arpit I used Qt Installer downloaded from their Website I didn’t use the package installer with apt-get. QtCreator is a deprecated package.

@underscore_d I used Qt Installer downloaded from their Website I didn’t use the package installer with apt-get. QtCreator is a deprecated package.

@C.Xammar Expected qt location will be:»/opt/qt-director name» move in that folder then run ./qtcreator.

4 Answers 4

Probably you can find the executable in opt directory the location will be as this /opt/Qt/Tools/QtCreator/bin and you can run it through terminal as ./qtcreator

Latest QtCreator should by default be installed in

And you have two start-up options, the executable qtcreator or the shell script qtcreator.sh

To run the executable, type

~/Qt/Tools/QtCreator/bin/qtcreator 

To run the shell script, type

~/Qt/Tools/QtCreator/bin/qtcreator.sh 

Whic one to use: From the top portion of qtcreator.sh , it states that if you have library name conflicts (such as having same library names used by qtcreator with your own LD_LIBRARY_PATH ), you may want to start with the shell script, rather than the bare executable.

Windows linux subsystem users

In case you have ubuntu as a subsystem for win10, it’s located in your AppData folder (installing with sudo apt install command): Also, you cannot run qtcreator from terminal as graphical interface is not supported by defeault. You need to instal X-server app first (https://sourceforge.net/projects/xming/) and then you can run QT from terminal.

C:\Users\[YOUR_USERNAME]\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\usr\share\qtcreator 

Or, it’s in usr/lintian/overrides

But you should not modify anything inside this linux root, as it may lead to data loss.

Источник

Using Command Line Options

You can start Qt Creator and specify some options from the command line. For example, you can open a file to any line and column. To specify command line options, enter the following command in the Qt Creator installation or build directory: qtcreator [option] [filename[:line_number[:column_number]]]

Note: You can use either a colon (:) or a plus sign (+) as a separator between the filename and line number and the line number and the column number. You can also use a space between the separator and the line number.

  • C:\qtcreator\bin>qtcreator -help
  • C:\qtcreator\bin>qtcreator C:\TextFinder\textfinder.cpp:100:2
  • C:\qtcreator\bin>qtcreator C:\TextFinder\textfinder.cpp +100+2

To open a project that is located in a particular folder, you can pass on the folder name as a command line argument. Qt Creator looks for a session that matches the folder name and loads it. Or it looks for a project file in the folder and opens it. For example:

Note: To run a self-built Qt Creator from the command line on Windows, make sure that the Qt installation directory is included in the PATH environment variable. You can enter the following command on the command line to add Qt to the path:

set PATH=Qt_installation_directory>\mingw\bin;c:Qt_installation_directory>\bin;%PATH%

The following table summarizes the available options:

Option Description
-help Display help on command line options.
-version Display Qt Creator version.
-client Attempt to connect to an already running instance of Qt Creator.
-pid Attempt to connect to an already running instance of Qt Creator with the specified process ID.
-block Open files in editors in a running Qt Creator instance and block the command line until the first editor is closed.
-nocrashcheck Disable the startup check for a previously crashed Qt Creator instance.
-load Enable the specified plugin and all plugins that it depends on. You can combine -load and -noload options and specify both options multiple times to enable and disable several plugins. The actions are executed in the specified order.
-load all Enable all plugins.
-noload Disable the specified plugin and all plugins that depend on it.
-noload all Disable all plugins.
-profile Output profiling data about plugin startup and shutdown.
-pluginpath Add a path where Qt Creator looks for plugins. To specify several paths, add the -pluginpath option for each path.
-settingspath Override the default path where user settings are stored.
-installsettingspath Override the default path from where user-independent settings are read (for example written by the installer).
-temporarycleansettings, -tcs Use clean settings for debug or testing reasons. The settings will be deleted when Qt Creator exits.
-language Set the UI language.
-test [,testfunction[:testdata]] . For Qt Creator plugin developers: run the plugin’s tests using a separate settings path by default.
-test all For Qt Creator plugin developers: run tests from all plugins.
-notest For Qt Creator plugin developers: exclude all of the plugin’s tests from the test run.
-scenario For Qt Creator plugin developers: run the specified scenario.
-color Core plugin: override the selected UI color.
-presentationMode Core plugin: display keyboard shortcuts as popups when you press them. Mostly useful when presenting Qt Creator to someone else.
-theme Core plugin: apply a dark color theme to Qt Creator, without using stylesheets.
-notour Welcome plugin: skip the UI tour on startup.
-debug Debugger plugin: attach to the process with the given process ID.
-debug [,kit=] Debugger plugin: launch and debug the executable with the name executable . A kit can be specified by ID or name to point to non-default debuggers and sysroots.
-debug [executable,]core=[,kit=] Debugger plugin: load the core file named corefile . The parameter executable specifies the executable that produced the core file. If this parameter is omitted, Qt Creator will attempt to reconstruct it from the core file itself. This will fail for paths with more than about 80 characters. In such cases the executable parameter is mandatory. A kit can be specified by ID or name to point to non-default debuggers and sysroots.
-debug ,server=[,kit=] Debugger plugin: attach to a debug server running on the port port on the server server . The parameter executable specifies a local copy of the executable the remote debug server is manipulating. A kit can be specified by ID or name to point to non-default debuggers and sysroots.
-wincrashevent Debugger plugin: attach to crashed processes by using the specified event handle and process ID.
-git-show Git plugin: show the specified commit hash.
-customwizard-verbose ProjectExplorer plugin: display additional information when loading custom wizards. For more information about custom wizards, see Adding New Custom Wizards
-ensure-kit-for-binary ProjectExplorer plugin: create a kit with a toolchain corresponding to the given binary’s architecture.
-lastsession ProjectExplorer plugin: load the last session when Qt Creator starts. Open the projects and files that were open when you last exited Qt Creator. For more information about managing sessions, see Managing Sessions.
ProjectExplorer plugin: load the given session when Qt Creator starts. Open the projects and files that were open when you last exited Qt Creator. For more information about managing sessions, see Managing Sessions.

Using Custom Styles

Qt Creator is a Qt application, and therefore, it accepts the command line options that all Qt applications accept. For example, you can use the -style and -stylesheet options to apply custom styles and stylesheets. The styling is only applied during the current session.

Exercise caution when applying styles, as overriding the existing styling may make some items difficult to see. Also, setting a stylesheet may affect the text editor color scheme and the styling of the integrated Qt Designer.

You can also switch to a dark theme to customize the appearance of widgets, colors, and icons without using stylesheets.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Источник

Getting Started on the Commandline

Welcome to C++! This guide will show you how to get started with C++ application development with Qt. Before you continue you may want to start downloading the Qt SDK from here. Choose the Community version if unsure. The source code examples in this guide are entirely LGPL compatible. On Linux you can also just install libqt4-dev and g++ using your favorite package manager.

«Hello, world!» console application

Let’s begin with a simple C++ program. Open a text editor and enter the following source code. Keep care to type it exactly like shown in the following example. Like most programming languages C++ is case-sensitive.

#include int main()  QTextStream(stdout)  <"Hello, world!"  <endl; return 0; > 

Create a directory «hello» and save the source code into a file hello.cpp residing in this directory.

The download of the Qt SDK or package install should be finished by now.

Open a shell and inspect which version of Qt you have installed: enter «qmake -v». If qmake can’t be found you have to add its installation path to your environment variable. Search for it in the SDK installation directory.

Now enter the «hello» directory and type: «qmake -project». This will create an qmake project file. Thereafter run just «qmake» without arguments. this will create a «Makefile» which contains the rules to build your application. Then run «make» (called nmake or gmake on some platforms), which will build your app according to the rules layed out in the «Makefile». Finally you can run the app «./hello».

So, on a bash command prompt you would enter:

$ cd my/dir/hello $ qmake -project $ qmake $ make $ ./hello

«Hello, world!» desktop application

Simply replace the source code in hello.cpp by:

#include #include #include int main(int argc, char **argv)  QApplication app(argc, argv); QLabel label("Hello, world!"); label.show(); return app.exec(); > 

Add the following lines to the .pro file after the include path:

. INCLUDEPATH += . QT += gui QT += widgets .

Run «qmake» and then «make» again. If you launch the application should see a small window saying «Hello, world!».

At this point I hope you were able to take the first step in C++ development using Qt. You may now want to start reading some of Qt’s documentation. Qt’s API reference is directly written by the software developer that create Qt. You find the latest API documentation at doc.qt.io. For instance go to QLabel to learn more about the «QLabel» class. Another good starting point is to take a look at the examples, which ship with Qt. If you have chosen to install the Qt SDK and you launch the Qt creator you can open the examples directly from the start page.

Источник

How to run console application written on Qt creator in terminal? [duplicate]

In project setting there is a check box to run application in terminal window (-I don’t remember exact name of check box, but it is easy to find). You will see separate widow when running application.

Problem is debugging. For a longer time there is bug in GDB (used by Qt Creator on all platforms) when debugging console application and waiting for data from console. To overcome this problem prepare file with input data and redirect standard input to this file.

If you run application in normal mode (no debugging) console input works fine.

Yes, this chek box exist in case you are using *.pro file for qmake in your project. Unfortunately, I didn`t find any similar chek boxes in case of CMake-project. Maybe you know any other way to solve this issue. Maybe is reason to type something extra to Cmakelist.txt file (similar way as configuration files, for example like here)

this is not a setting which is written in *.pro file! It is recorded somewhere in qt creator files for workspace, so same thing applies for any kind of project. I need other machine to prove it.

did you clicked «Projects» icon on the left? On this page there are build/run settings, where this check box is located.

Yes it works. I clicked Priject then move Build&Run section, then change Buld into Run and see the Run in terminal check box. So, after I filled this chekbox my application run on separate terminal window :). Thank you so much!

@MarekR I know it’s been some years but I think the GDB bug is still there as I’m getting «Build ID mismatch between current exec-file and automatically determined exec-file» warning if I run my app in terminal. The link you provided no longer exists and I don’t really know what you meant by «redirect standard input to this file». Could you elaborate, if you remember it?

Источник

Читайте также:  Linux find all files exec
Оцените статью
Adblock
detector