How about if use GUI class in QT CLI application?










1














I am developing a Qt CLI application.
I know that we should only use the class of CORE lib



QT -= gui
CONFIG += console


But I want to use QStandardItemModel for a tree view (show on console window).
How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application.



P/s: Could I create a standard tree model for developing both GUI and CLI application instead of QStandardItemModel (only work on GUI)?










share|improve this question























  • I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
    – vahancho
    Nov 13 '18 at 8:34










  • How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
    – kien bui
    Nov 13 '18 at 8:36










  • I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
    – kien bui
    Nov 13 '18 at 8:40










  • You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
    – Felix
    Nov 13 '18 at 9:59















1














I am developing a Qt CLI application.
I know that we should only use the class of CORE lib



QT -= gui
CONFIG += console


But I want to use QStandardItemModel for a tree view (show on console window).
How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application.



P/s: Could I create a standard tree model for developing both GUI and CLI application instead of QStandardItemModel (only work on GUI)?










share|improve this question























  • I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
    – vahancho
    Nov 13 '18 at 8:34










  • How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
    – kien bui
    Nov 13 '18 at 8:36










  • I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
    – kien bui
    Nov 13 '18 at 8:40










  • You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
    – Felix
    Nov 13 '18 at 9:59













1












1








1







I am developing a Qt CLI application.
I know that we should only use the class of CORE lib



QT -= gui
CONFIG += console


But I want to use QStandardItemModel for a tree view (show on console window).
How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application.



P/s: Could I create a standard tree model for developing both GUI and CLI application instead of QStandardItemModel (only work on GUI)?










share|improve this question















I am developing a Qt CLI application.
I know that we should only use the class of CORE lib



QT -= gui
CONFIG += console


But I want to use QStandardItemModel for a tree view (show on console window).
How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application.



P/s: Could I create a standard tree model for developing both GUI and CLI application instead of QStandardItemModel (only work on GUI)?







qt console qt5 qstandarditemmodel treemodel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 8:35







kien bui

















asked Nov 13 '18 at 2:16









kien buikien bui

6421023




6421023











  • I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
    – vahancho
    Nov 13 '18 at 8:34










  • How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
    – kien bui
    Nov 13 '18 at 8:36










  • I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
    – kien bui
    Nov 13 '18 at 8:40










  • You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
    – Felix
    Nov 13 '18 at 9:59
















  • I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
    – vahancho
    Nov 13 '18 at 8:34










  • How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
    – kien bui
    Nov 13 '18 at 8:36










  • I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
    – kien bui
    Nov 13 '18 at 8:40










  • You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
    – Felix
    Nov 13 '18 at 9:59















I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
– vahancho
Nov 13 '18 at 8:34




I think you can sub class the QAbstractItemModel and use it without linking to QtGui module, as QAbstractItemModel is in QtCore and independent from GUI.
– vahancho
Nov 13 '18 at 8:34












How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
– kien bui
Nov 13 '18 at 8:36




How about if I set Qt += gui and include QStandardItemModel in my code and develop a CLI application? What problem or conflict?
– kien bui
Nov 13 '18 at 8:36












I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
– kien bui
Nov 13 '18 at 8:40




I can set QT += GUI But I am not sure that what problem or conflict when I set GUI for CLI app.
– kien bui
Nov 13 '18 at 8:40












You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
– Felix
Nov 13 '18 at 9:59




You can easily add QT += gui without any problems and continue to use a QCoreApplication, as long as you do not use any class that might show anything GUI-related. If you ever do accidentily, Qt will print a warning and not just crash, so it's pretty safe to use that way
– Felix
Nov 13 '18 at 9:59












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272810%2fhow-about-if-use-gui-class-in-qt-cli-application%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272810%2fhow-about-if-use-gui-class-in-qt-cli-application%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto