In any Qt application on KDE when I add a QPushButton in designer and check it's text by:
void MainWindow::on_pushButton_clicked()
{
qDebug()<<ui->pushButton->text();
}
The output is preceded by an & :
&PushButton
This behavior does not exist on Windows. It seems that Qt applications on KDE automatically add shortcuts to all push buttons, which is not desired for me. I should note that the ampersands are not created by designer and you can not see them in the.ui file. Actually when the button is added to a widget, an & is placed somewhere in it's text.
Is it possible to disable automatic mnemonics of a Qt application in anyway?
KDEPlatformTheme plugin responsible for it.
A workaround is to add
[Development]
AutoCheckAccelerators=false
to ~/.config/kdeglobals, which prevents KDE from automatically adding accelerators.
Related bug: https://bugs.kde.org/show_bug.cgi?id=337491
Related
I'm trying to create a Qt application with tabified QDockWidgets.
I know there is a QMainWindow::tabifyDockWidget to tabify QDockWidgets but since I'm doing everything related to UI in Qt Designer, I was wondering if there is some option in the designer to do so without adding extra code.
I wrote an application in Visual Studio and I needed to create a GUI for it so I decided to use Qt and I'm having a small but weird problem.
Let's say I add a Push button to the GUI in the Qt Designer. When I build the Application the UI Compiler creates the corresponding header file "ui_myApp.h" which has the new Push button.
When I Try to access the new Button and connect Signals and Slots the I can't find the Button. I only see old Widgets that I added before the Last build. It actually should show me "pushButton_2" and "pushButton_3" but I have only access to the pushButton and other Widgets before the last build.(See Figure)
I Checked the headerfile "ui_myApp.h" and the new Widgets are actually there. The Header file is correctly included. When I run my Application the new Button and new Widgets are there too. Why can't I access them when Connecting Signals and Slots in "myApp.cpp"??
Thanks!
Update
This may or may not help anyone. But if anyone ever faces the problem here how I solved it:
Each time I add new Widgets to my GUI using QT Designer I save the changes in the Form. Then I clean the Solution and Rebuild. Then I close Visual Studio and start it again. The new Widgets are accessible after these action. Not sure why.. but it does the job.
How to create an application which stays in top of MacOS, something similar to below image. You can see the Evernote elephant icon.
I don't want to use xcode - because my application already built in QT, it has nice GUI, now I wanted to add extended feature something similar to Evernote. If I click on an elephant it will open a dialog box to write notes. In my case- it's a simple event like on/off buttons.
I have tried and created GUI widget apps but how to make one which resides like Evernote app ?
A custom pop up menu like the one pictured can be done several ways in Qt.
QML is the most modern way of making the menu with the customized styling you are looking for.
Apply the appropriate flags to the window/widget so it appears as a popup.
The same effects can also be done in QWidgets, but takes more code and probably will take longer to make. The flags you are looking for will be found under Qt Window Flags and/or under Qt Widget Attributes.
The stock stylings for Qt for different OS's deal mostly with title bars, status bars, buttons, drop downs, etc.
The base styles for Mac can be found here:
http://doc.qt.io/qt-5/gallery-macintosh.html
Once you go to a customized popup, you have to draw all of it yourself... but the native drawing elements in Qt are friendly enough and get you that look you are trying to do.
There are even some tools for exporting from Photoshop or Gimp directly to QML.
http://doc.qt.io/qtcreator/quick-export-to-qml.html
Hope that helps.
You are looking for a tray icon. Qt implements it in QSystemTrayIcon.
Further information
You may take a look at the System Tray Icon Example.
Many StackOverflow posts exist on this topic.
If you already have a program written for Qt, then you can compile and run it under MacOS/X much the same way you could compile it under (whatever OS you're using now). You'll need to install Xcode because Xcode includes the C++ compiler (clang) you'll need in order to compile your Qt program, but you don't have to use the Xcode IDE if you don't want to. Rather, you can either use the QtCreator IDE under MacOS/X, or you can simply open up a Terminal window and do a "qmake ; make" in the directory where your Qt-based program's .pro file is, and build it from the command line that way.
If, on the other hand, your question is actually about how to add an icon to the global menu of a MacOS/X desktop, then I don't think Qt has an API for that, so you'll need to drop down to using one of MacOS/X's native APIs. That will probably involve learning some Objective-C (or Objective-C++, if you prefer), but integrating a bit of Objective-C/C++ into your Qt app is doable with a bit of work.
I have a custom widget subclassed from QPushButton, MyButton. It's implemented in a single .cpp file and I'm using it in Qt Creator in my application's form (I've added a QPushButton then promoted it to MyButton).
As discussed here: Should I really use a single qss file for my application instead of having one for each (UI) class? I wish to generally set its CSS inside its constructor (the general look of the button, the background image, hover behavior etc), but I would also like to be able to set it in Qt Creator (maybe customize the font size/color; generally specific to a particular button).
The issue is, as the setupUi call is issued, my buttons are created, they set their styles in their constructors, but then Qt applies the styles set in Qt Creator, immediately overriding mine.
What can I do to achieve this effect?
I am creating a Qt GUI with C++.
My intention is to prompt the user when the tab bar is double clicked or single clicked. This works when I create the GUI using Qt Creator; however, when I qmake and run with XCode, the GUI does not respond to either single or double clicks.
I am using the signals tabBarDoubleClicked(int) and tabBarClicked(int) from QTabWidget.
Why do I experience different behavior when building with Qt Creator as opposed to XCode?
How can I make XCode recognize single and double clicks to the tabBar?
Edit: Also, I cannot find documentation for these functions. I find that strange due to Qt Creator listing this as applicable signals. Why?
One possible option is - as you write in the comment -, that you are using different Qt versions.
Another option in general is that people invoke qmake slightly different, e.g. from a different folder than QtCreator, etc.