Application starts but dont show UI
-
Hello.
When I compile and run my Application from within Qt Creator, it compiles and starts fine but the UI dont show up.
System / Software Specs:
- Antergos with Plasma 5 (KDE5), x64
- GCC 6.1.1 x64 from the Antergos Repo
- Qt 5.6.0 from Antergos Repository [Qt 5.6.1 is still in testing Repo - therefore untested yet]
- Qt Creator 4.0.1 from Extra Repo
- Qt Creator 4.0.1 from downloads.qt.io
I have not tested a self compiled Qt 5.7.0 yet - I will do this when the Final is out. Have not compiled Qt under Linux myself yet: Need to read some more Tips still. And I am still a beginner when it comes to developing under Linux.
In the .pro File I also use
linux:QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks
Which should be used in some cases according to the Internet. But it makes no difference if this Parameter is used or not.
The used Modules are:
QT += core gui webenginewidgets xml widgets sql qtHaveModule(printsupport): QT += printsupport
I use some qDebug() Functions to Log some things:
- The SQLite Database is correctly opened and the connection is fine
- The App has a Thread ID
- KSysGuard shows the correct App Thread ID
I have used MinGW under Windows (now VS2015 as I switched to QtWebEngine). But GCC under Linux is still somehow new to me.
This Problem does not exist with GCC 5.x or 4.9.xDoes anyone else have a similar experience?
Thank you for your time :)
Oliver -
Can you show your code? Especially how you initialize your UI?
-
Nothing special. I have 1 QStackedWidget which contains 3 different Widgets. Everything works up to GCC 5.x and VS2013 / VS2015.
Snippet of MainWindow.cpp:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::AKToolMainWindow) { ui->setupUi(this); //Own QStackedWidget for: Layouts, QMenu and everything else. mainWindowStackedWidget = new QStackedWidget(this); //Different QWidgets for different Layouts onlyBrowser = new QWidget(this); onlyTextEditor = new QWidget(this); onlyDatabase = new QWidget(this); //onlyOpenAntrag = new QWidget(this); //Add the QWidget's to mainWindowStackedWidget mainWindowStackedWidget->addWidget(onlyTextEditor); mainWindowStackedWidget->addWidget(onlyDatabase); mainWindowStackedWidget->addWidget(onlyBrowser); //Different qGridLayout's for different Viewports... showOnlyTextEditor = new QGridLayout(onlyTextEditor); showOnlyDatabase = new QGridLayout(onlyDatabase); listOfTools = new CToollist; showDefaultStartupViewpoint = new QGridLayout(onlyBrowser); //Simple File Editor uiTextEditor = new CTextEditor(this); uiTextEditor->setObjectName(QString::fromUtf8("TextEditor")); //Database Widget uiDatabase = new CDatabase(this); uiBrowser = new CBrowser(this); //Add the specific Layouts to the GridLayout's... //Default Layout Settings at startup showDefaultStartupViewpoint->addWidget(uiBrowser,0,0); //0,1,1,1 //Database Viewpoint only showOnlyDatabase->addWidget(uiDatabase, 0,0); //OpenAntrag Viewpoint only //showOnlyOpenAntrag->addWidget(m_OpenAntrag, 0,0); //TextEditor Viewpoint only showOnlyTextEditor->addWidget(uiTextEditor, 0,0); //Set the Default Viewport mainWindowStackedWidget->setCurrentWidget(onlyTextEditor); //Set mainWindowStackedWidget->defaultStartupViewport as central Widget and activate it setCentralWidget(mainWindowStackedWidget); //Toolbars for TextEditor toolBarEdit = new QToolBar(this); toolBarEdit->setDisabled(false); toolBarEdit->setObjectName(tr("Edit Actions")); //toolBarEdit->setMovable(true); addToolBar(toolBarEdit); //addToolBarBreak(Qt::TopToolBarArea); toolBarFormat = new QToolBar(this); toolBarFormat->setDisabled(false); toolBarFormat->setObjectName(tr("Formatierung")); toolBarFormat->setHidden(false); addToolBar(toolBarFormat); addToolBarBreak(Qt::RightToolBarArea); toolBarFontSize = new QToolBar(this); toolBarFontSize->setDisabled(false); toolBarFontSize->setObjectName(tr("Schriftgröße")); addToolBar(toolBarFontSize); //Toolbar for Webbrowser toolBarWebbrowser = new QToolBar(this); toolBarWebbrowser->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Back)); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Back)->setToolTip(tr("Eine Seite zurück blättern")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Back)->setStatusTip(tr("Eine Seite zurück blättern")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Back)->setWhatsThis(tr("Eine Seite zurück blättern")); toolBarWebbrowser->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Forward)); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Forward)->setToolTip(tr("Eine Seite vorwärts blättern")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Forward)->setStatusTip(tr("Eine Seite vorwärts blättern")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Forward)->setWhatsThis(tr("Eine Seite vorwärts blättern")); toolBarWebbrowser->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Reload)); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Reload)->setToolTip(tr("Aktuelle Seite erneut laden")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Reload)->setStatusTip(tr("Aktuelle Seite erneut laden")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Reload)->setWhatsThis(tr("Aktuelle Seite erneut laden")); toolBarWebbrowser->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Stop)); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Stop)->setToolTip(tr("Laden der Seite abbrechen")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Stop)->setStatusTip(tr("Laden der Seite abbrechen")); uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Stop)->setWhatsThis(tr("Laden der Seite abbrechen")); addToolBar(toolBarWebbrowser); //addToolBarBreak(Qt::RightToolBarArea); toolBarWebbrowser->setDisabled(false); toolBarWebbrowser->setHidden(false); //Toolbar for Database (ignore: its only for Layout testing yet) toolBarDatabase = new QToolBar(this); toolBarDatabase->setDisabled(true); toolBarDatabase->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Back)); toolBarDatabase->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Forward)); toolBarDatabase->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Reload)); toolBarDatabase->addAction(uiBrowser->m_BrowserModule->pageAction(QWebEnginePage::Stop)); toolBarDatabase->setHidden(false); addToolBar(toolBarDatabase); //Read saved Application Settings from ini File. //FIXME If first app start == true, create Default INI Entries with default settings... readAppSettings(); createMenu(); //Activate MainLayout in mainWindowWidget mainWindowStackedWidget->show(); qDebug() << "MainWindow Thread" << QThread::currentThread(); }
The uiTextEditor, uiBrowser and uiDatabase are QWidgets with a UI File created externally in Designer. Like i said, nothing special. But as this App is WIP and I am no C++ Pro, I am sure there are badly designed "things" somewhere.
Thanks
-
Hi
where is the
ui->setupUi(this);
line?
should be first line in constructor ? -
@MeerMusik
damn. would been too easy.If you create a new project, does it work then ?
(with the compiler that caused your issue) -
Some "Standard" Stuff like a "Hello World" Example works. More "complicated" Code like Widgets with UI sometimes works, sometimes not as in they compile but dont show the UI. I cant show Data yet as I am currently on my Windows Machine.
It really seems there is more broken / defect than NULLPTR checks / handling within GCC6. Unfortunately more Tests have to wait until the weekend.
Thanks again.
Have a nice week :)
Oliver -
Well much sooner as I had planned as I had to backup some things to Linux and to update some stuff. Totally forgot about that. Anyway:
I installed the pre-compiled "5.7.0 Final Linux x86_64 Snapshot" from [https://download.qt.io/snapshots/qt/5.7/5.7.0/450/] and what can I say: The GUI shows up.
A quick look through the Internet resulted in this (first time usage of this Tool: Result should be correct):
readelf -p .comment /home/oliver/developing/Qt5.7.0/5.7/gcc_64/lib/libQt5Core.so String dump of section '.comment': [ 0] GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-9) [ 2c] GCC: (GNU) 4.9.1 20140922 (Red Hat 4.9.1-10)
As 4.4 is too old, I think this Package was compiled with GCC 4.9.1
So: The combination of
Installed GCC 6.1.1-2 + 5.7.0 compiled with GCC 4.9.1 works. (Only quick "GUI-shows-up" Test: Nothing else checked yet)At this point, I dont know If it is because
1.) Qt was compiled with GCC 4.9.1 or
2.) because Qt 5.7.0 already contains some GCC6 fixes(?)
3.) or a combination of both.Fact (in my personal case) is: The Qt 5.6.0 Package provided from Arch-Extra has some Problems. As 5.6.1 is still in Arch-Testing, I have no experience with that Qt Version either.
Also untested: Installed GCC 6.1.1-x + self-compiled Qt 5.7.0 Final GCC 6.1.1 Build
Good Night everyone :)
-
@MeerMusik Ok, then i use archlinux and also antergos a lot. the easy way is to use package installation from pacman tool, or with pacaur if you want some aur things... for me, everything (except exceptions) works out of this packages box (and also you would be on the "stable" edge to).
Don't forget to pass your question as "resolved". -
@jerome_isAviable As soon as it is solved, I will mark it as such. But as long as "it" can come back with a pure GCC 6 usage, it is not solved. Qt 5.7.0 Final is close. I need to self-compile it for OpenSSL Support and then I will have the results. Hopefully latest on next Sunday.