QWidget::showMinimized() doesn't work - qt

On Ubuntu 13.04, if using QWidget::showMinimized() to minimize a window, I found that after restoring it by clicking the app icon the system taskbar, recalling the QWidget::showMinimized() cannot work.
connect(minimumBtn,SIGNAL(clicked()),this,SLOT(minimumWin()));
minimumWin(){
showMinimized();
}
showMinimized() in minimumWin() doesn't work anymore if it has been called before (even the window is showed).

I can reproduce this with Linux Mint and Qt 5.1. It is most probably a bug in Qt. I found that if you call showNormal() right after showMinimized(), the window minimizes and after it is restored from the taskbar, it is possible to minimize the window again. For example:
void MainWindow::on_pushButton_clicked()
{
showMinimized();
showNormal();
}

I've met this problem, but I didn't solve it completely
In ubuntu system, you can use this function in your QWidget class constructor:
this->setWindowFlags(Qt::Window|Qt::FramelessWindowHint||Qt::WindowMinimizeButtonHint);
then the showMinimized() is valid to use (there is no frame and a minimize button when code running, if you have, then you're with me).
But it's only valid in ubuntu system, and this method is invalid in my company's customized (like ubuntu) operate system. I don't know why.

Related

QWebView shows blank page on Raspberry Pi 2

I am developing a Qt Web Kit application to run on Raspberry Pi 2. When I run the application on Ubuntu 14.04 on desktop it runs as expected. However when I run it on my Raspberry only blank page is shown. I also tried setting other HTML pages in QWebView, but that also ended in blank pages. I tried local HTML files, the ones from the internet and I even tried setting HTML text from code myself with setHtml(const QString &html) function. Sometimes, and I don't know why, depending on QString I set as HTML i get "$66" written in top left corner of the screen. It just doesn't make sens to me. At the end of the question are functions which I use to set web kit and web view. Is the problem maybe that I need to enable something or set some other parameters of MainWindow, which is inherited from QWebView? In my HTML I have a lot of images, actually that is all there is. I thought that was the problem, but simple HTMLs and some sites like google don't work too, so I ruled that problem out. Here is the code. It is compiled and there are no exceptions while running it, but it doesn't work as expected.
void MainWindow::initializeWebKit()
{
_network = new QNetworkAccessManager(this);
_cache = new QNetworkDiskCache(this);
_cache->setCacheDirectory(CACHE_DIRECTORY);
_cache->setMaximumCacheSize(CACHE_SIZE);
_network->setCache(_cache);
page()->setNetworkAccessManager(_network);
}
void MainWindow::initializeFrontend()
{
QUrl startURL = QUrl("qrc:/Web/index.html");
setUrl(startURL);
}

Change virtual keyboard to AZERTY

I have a javafx application that is supposed to run in fullscreen mode on a Windows tablet.
My problem is, when the keyboard appears, it's in QWERTY whereas my tablet is in AZERTY.
So the question is : Is there a way to use the system virtual keyboard or to switch the javafx virtual keyboard to AZERTY?
I found you question while trying to accopllish the same thing.
I spent a day trying to make javafx display an AZERTY keyboard and i found a solution!
Well let me be clear : javafx gave no way at all to have an azerty keyboard so you have to hack a little.
The solution bellow is not a perfect one and you'll have to repeat it each time you update javafx, but it will allow you to extrem customize the keyboard far beyong querty and azerty.
SOLUTION 1 (dirty but works )
You will need to edit a file in javafx file shipped with the JDK
STEPS :
GO to the JDK (in Mac : /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home)
Go inside jre/lib/ext and copy javafx jar called jfxrt.jar to a folder on your desktop.
Install EMACS if you don't have it and open the copied jar file with this software
Browse files list searching for com/sun/javafx/scene/control/skin/TextBoard.txt
the list is sorted from A-Z so use it (there is more than 6000 files).
Open it and HERE you are. Change characters to whatever order makes you happy. I joined the azerty order.
Save and copy back the jfxrt.jar to where it was. Done.
Note: don't try to extract the jar and rezip it, it won't work as jdk keeps an index list of files.
Result:azerty javafx virtual keyboard in action
SOLUTION 2 (Clean but i didn't finish it)
Whene i digged into javafx classes i found out that the class responsible for loading the TextBoard.txt file that lays out the keyboard is FXKVSkin
This class is meant to receive other type of keyboards than the lonly qwerty default one.
All you have to do is add this in your code :
textFieldThatYouUse.getProperties().put(FXVK.VK_TYPE_PROP_KEY,
"mykeyboard");
Where mykeyboard is a file you created like TextBoard.txt called MykeyboardBoard.txt (capitals letters are important).
FXKVSkin will look now for a file called MykeyboardBoard.txt, and here's where my adventure ended.
You will need to make FXKVSkin find your file, i tried by adding a file to the classpath at runtime solutions Here but it didn't work.
If anyone can solve this problem, please add it as an answer, it would be a less dirty solution.
Hope the solutions will help some non english speakers! :p
The definition of the layout is contained in jfxrt.jar (part of the Java install). It is described by TextBoard.txt. It is possible to browse in the jfxrt.jar with 7zip or similar programs. TextBoard.txt is in com/sun/javafx/scene/control/skin/
This file is loaded com/sun/javafx/scene/control/skin/FXVKSkin.java is responsible for loading the TextBoard.txt file. Browse the javafx source (included via the jdk and contained in javafx-src.zip) to see how it is processed. Maybe this will give you enough information to load your own TextBoard.txt file.

Gtk skip_taskbar_hint (seen in Glade-ui-Designer) äquivalent in Qt

With Glade Designer that lets you set up Gtk-Ui's you can check the option that windows are not shown in the taskbar (unter linux, e.g. in Ubuntu this is the launcher on the left hand side). If I take a look at the ui-file generated by Glade, it says <property name="skip_taskbar_hint">True</property> However I believe that this option is not Gtk-specific, and want to apply this one on my PyQt4-app.
Right now I can only disable the window in the taskbar if i set the hint with the programm devilspie (that communicates with EWMH-standard) to skip_tasklist, which is too much for me.
Does anybody know such an option?
It seems that Qt::SplashScreen does the same effect. You can add this flag to your widget using the following code:
setWindowFlags(windowFlags() & Qt::SplashScreen);
Source

How to change an initial size of qtcreator's qtcreator_process_stub window (on Ubuntu)?

I have an application being developed in QT Creator on Ubuntu. I need to run some tests and to see their results I use console — qtcreator_process_stub window is opened. And now comes my question: how to set its initial size? (especially the width to make results more readable). Setting the width by mouse each time I run my app is quite annoying.
I found a simple solution:
Go to Tools->Options->General->Environment: System->Terminal. There is a command used to invoke a terminal. In my case I needed to change the command to:
xterm -geometry 250 -e
That's all;)
Maybe it will be useful for Windows users:
You can right click on the console title bar (when running your program), select properties and change the font size (or other properties) in the font tab. It will be remembered for the future sessions.
For changing console size from command starts console use cmd.exe "/k mode con: cols=150 lines=50" (not working from Qt for me, changing COMSPEC do nothing).
In more recent versions of Qt Creator (2.6.2 and up) this can be changed in
Projects
Run (from the top of the window)
In the run environment edit the COMSPEC field
On Linux Mint you can do the following:
Open Terminal
Edit -> Profile Preferences -> General -> Use custom default terminal size
Set the Default size to a value which fit your needs.

How can I get a QFileDialog to prompt for overwrite?

I have a QDialog that opens a QFileDialog like so:
QFileDialog fd(this);
fd.setFileMode(QFileDialog::AnyFile);
if (fd.exec()) {
// save data to a file
}
Unfortunately, the default behavior doesn't seem to be quite so default, and the file dialog doesn't prompt me about overwriting if I select a file that already exists. Calling setConfirmOverwrite(true) or setOption(QFileDialog::DontConfirmOverwrite, false) first doesn't help either. I've tested this both on Qt 4.7.3 and 4.7.4 on both Ubuntu 11.04 and Windows XP.
I looked around and found this bug report. QFileDialog::getSaveFileName() had this issue, but it was specific to Maemo and fixed well before Qt 4.7.3 came out. If I use that method in my application it works just fine, I get prompted about overwriting the file. (I don't want to use getSaveFileName() for unrelated reasons.)
I can't find anyone else complaining about this not working for them. Am I doing something wrong, or is this a bug? I think it might be due to the dialog not knowing whether it's just a simple Open dialog where prompting wouldn't make sense, but I don't see a way to tell it it's a Save dialog (beyond setting the confirm-overwrite option, which fails), and the documentation does say it should prompt by default.
You should also be sure that the dialog is in save mode, as it will not think you are overwriting a file when in open mode. You can do this by calling fd.setAcceptMode(QFileDialog::AcceptSave); in your code example. See QFileDialog::acceptMode.

Resources