qt

c++ programming for joystick in windows

偶尔善良 提交于 2021-02-10 17:54:04
问题 i want to connect joystick to my c++ qt program in windows.I studied about programming with win32 api using the joystickapi library in microsoft guid for joystick program But I didn't understand exactly What should I do after checking the system compatibility? Completion description: my code for system compatibility: JOYINFO joyinfo; UINT wNumDevs, wDeviceID; BOOL bDev1Attached, bDev2Attached; void joyCapablitis(){ if((wNumDevs = joyGetNumDevs()) == 0) qDebug()<<"no driver available";

Can I use QCommandLineParser to determine GUI mode or CLI mode?

╄→尐↘猪︶ㄣ 提交于 2021-02-10 16:55:30
问题 One of the programs that I work with has two modes that it can run in: GUI (Graphical User Interface) mode or CLI (Command-Line Interface) mode. We determine which mode to use via a command line argument (i.e., if "--cli" is passed, it will use CLI mode). The type of QApplication that is instantiated depends on which mode is used: QApplication should be used for GUI mode, and QCoreApplication should be used for CLI mode, because the GUI parts of Qt should not be instantiated for CLI mode

I have two webcams, but QCameraInfo::availableCameras returns empty array

▼魔方 西西 提交于 2021-02-10 16:15:23
问题 According to the documentation, QCameraInfo::availableCameras should return list of available cameras. There's no catch to it according to the docs. But still, I have two webcams and the array of available cameras is returned empty. What can I do? Is this even in the scope of programming, or does this mean Qt only supports limited subset of webcams? The OS I'm using right now is Windows 7x64. 回答1: I have this Problem too.Then I read about the example. I found that once you have declared

How to include QtQuickControls

☆樱花仙子☆ 提交于 2021-02-10 15:59:00
问题 I've included to my project : "import QtQuickQontrols 1.4" But now I need to use ScrollBar , and for this, I need to include "import QtQuickControls 2.2" But when I include version 2.2 and delete 1.4, my project is ruined... MenuBar, TableView is under errors! Ok, when I include both this version it's errors , too! I did run qmake, and give me some advice what should I do to implement my ScrollBar. I've tried to add ScrollView, but inside this it doesn't work : .... ScrollBar.vertical:

QFileDialog: force file name

泄露秘密 提交于 2021-02-10 15:37:26
问题 I want to create a QFileDialog set to QFileDialog::AnyFile in which the file name is fixed (but the location can be changed). So far I found the question QFileDialog - Saving a file with specified file name, which was not answered. There is the pseudo-answer of choosing the directory directly instead, which is what I did so far in my project. However, by people testing the program, this was found to be confusing, thus is not an acceptable answer. What I tried so far is to derive QFileDialog

What is the alternative to QTimer?

巧了我就是萌 提交于 2021-02-10 15:06:03
问题 The slot function QTimer::start have a interval of millisecond: Starts or restarts the timer with a timeout interval of msec milliseconds. But msec is a int type and couldn't take a long interval. What is a alternative to QTimer which could take a long interval ? 回答1: In this case you can use something like an hourly timer connected to a function or lambda that checks the current timepoint against a target... /* * We want to trigger some event one year from now. */ auto endpoint = QDateTime:

Injecting a mock of a QTimer

独自空忆成欢 提交于 2021-02-10 14:48:41
问题 I'm writing a unit test with QTest for a legacy code like: #include <QTimer> class MyObject: public QObject{ public: void foo(){ t1.start(500); } private: QTimer t1{this}; }; And want to mock a QTimer and then test if the QTimer::start(int) is properly called. I was trying several approaches. Dependency injection with template template<typename TIMER = QTimer> class MyObjecr: public QObject , but getting Template classes not supported by Q_OBJECT And LD_PRELOAD=libQTimerMock.so with a simple

How to make height of a QPushButton automatically fit the text?

白昼怎懂夜的黑 提交于 2021-02-10 14:21:52
问题 I have a QPushButton QPushButton *btn = new QPushButton(); btn->setText("Push \n Button"); The result is: I have tried btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred) with Qt Designer but it does not help. How can do so that the height of the button is automatically adjusted to fit with the content when I call setText ? 回答1: You can set the vertical size policy to an option that allows the widget to grow, the default option for vertical size policy of QPushButton is fixed,

How can I set a QFileSystemModel with information from another PC?

孤街醉人 提交于 2021-02-10 13:38:11
问题 I'm doing a college project where we need to set up a dropbox-like service in a local network. I can do it easily in a terminal, but for some extra points I'm trying to set up an QtPy ui for it. One of my widgets it's a QTreeView with a QFileSystemModel where I'd like to visualize the files and folders the user has saved on his "dropbox". The thing is, that the information and the folder itself are in another computer. I've tried sending the widget from one pc to another but you can't pickle

flickering white areas when resizing Qt window

ぐ巨炮叔叔 提交于 2021-02-10 09:31:29
问题 I am observing a strange behavior when resizing QWindow . When I resize the window so that both width and height are increasing or decreasing, then the window does not flicker with white background. But when I increase width while decreasing height (or vice versa) the window flickers and temporarily fill the new are with white color. This is a very annoying effect especially when I have a dark theme in my application and I resize the window. To experiment with this I used "rasterwindow"